Permalink
Browse files

Fix SUBSCRIBE and MONITOR when hitting a timeout.

  • Loading branch information...
1 parent a9cc7c4 commit cfde7ca24830aca6f0b3bd4ac341d85147e793a9 @djanowski djanowski committed Oct 20, 2010
Showing with 22 additions and 2 deletions.
  1. +4 −2 lib/redis/client.rb
  2. +18 −0 test/publish_subscribe_test.rb
View
@@ -37,8 +37,10 @@ def call(*args)
end
def call_loop(*args)
- process(args) do
- loop { yield(read) }
+ without_socket_timeout do
+ process(args) do
+ loop { yield(read) }
+ end
end
end
@@ -131,3 +131,21 @@
end
end
+test "SUBSCRIBE past a timeout" do |r|
+ # For some reason, a thread here doesn't reproduce the issue.
+ fork do
+ sleep OPTIONS[:timeout] + 1
+ Redis.new(OPTIONS).publish "foo", "bar"
+ end
+
+ received = false
+
+ r.subscribe "foo" do |on|
+ on.message do |channel, message|
+ received = true
+ r.unsubscribe
+ end
+ end
+
+ assert received
+end

0 comments on commit cfde7ca

Please sign in to comment.