Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle the case where timeout is nil in CZookeeper#wait_until_connected

  • Loading branch information...
commit 09abba44d0c551258021ece428a618606dc147d8 1 parent d859b2d
@slyphon slyphon authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 ext/c_zookeeper.rb
View
15 ext/c_zookeeper.rb
@@ -172,16 +172,21 @@ def state
# if timeout is nil, we never time out, and wait forever for CONNECTED state
#
def wait_until_connected(timeout=10)
- time_to_stop = Time.now + timeout
+ time_to_stop = timeout ? Time.now + timeout : nil
return false unless wait_until_running(timeout)
@mutex.synchronize do
while true
- now = Time.now
- break if (@state == ZOO_CONNECTED_STATE) || @_shutting_down || @_closed || (now > time_to_stop)
- delay = time_to_stop.to_f - now.to_f
- @state_cond.wait(delay)
+ if timeout
+ now = Time.now
+ break if (@state == ZOO_CONNECTED_STATE) || @_shutting_down || @_closed || (now > time_to_stop)
+ delay = time_to_stop.to_f - now.to_f
+ @state_cond.wait(delay)
+ else
+ break if (@state == ZOO_CONNECTED_STATE) || @_shutting_down || @_closed
+ @state_cond.wait
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.