Skip to content

Commit

Permalink
Prevent hang if multiple threads attempt to use an unconnected client
Browse files Browse the repository at this point in the history
  • Loading branch information
bpot authored and djanowski committed Jul 22, 2010
1 parent 8a84d72 commit 03cee15
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/redis/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ def synchronize(&block)
end

def ensure_connected(&block)
super do
synchronize(&block)
end
synchronize { super }
end
end

Expand Down
1 change: 1 addition & 0 deletions test/redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ class RedisTest < Test::Unit::TestCase
context "Thread safety" do
should "be thread safe" do
@r = prepare Redis.new(OPTIONS.merge(:thread_safe => true))
@r.client.disconnect

r1, r2 = nil

Expand Down

0 comments on commit 03cee15

Please sign in to comment.