Skip to content

Commit

Permalink
Merge pull request #333 from spiceworks/issue332
Browse files Browse the repository at this point in the history
Add synchronization around use of @cluster and other variables Fix #332
  • Loading branch information
pezra committed Oct 18, 2016
2 parents 4eb73e6 + 7e7d82a commit cfa015f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/cequel/metal/keyspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def self.sanitize(statement, bind_vars)
# @see Cequel.connect
#
def initialize(configuration={})
configure(configuration)
@lock = Monitor.new
configure(configuration)
end

#
Expand Down Expand Up @@ -241,15 +241,17 @@ def prepare_statement(statement)
# @return [void]
#
def clear_active_connections!
if defined? @client
remove_instance_variable(:@client)
end
if defined? @client_without_keyspace
remove_instance_variable(:@client_without_keyspace)
end
if defined? @cluster
@cluster.close
remove_instance_variable(:@cluster)
synchronize do
if defined? @client
remove_instance_variable(:@client)
end
if defined? @client_without_keyspace
remove_instance_variable(:@client_without_keyspace)
end
if defined? @cluster
@cluster.close
remove_instance_variable(:@cluster)
end
end
end

Expand Down

0 comments on commit cfa015f

Please sign in to comment.