Browse files

fix timeout behavior in reopen

use the timeout value given to the constructor if reopen is called
without a timeout param
  • Loading branch information...
1 parent 95ce4f8 commit e28c43070e12e625582f444f38ec2ff615cc62d0 @slyphon slyphon committed Jun 5, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/zk/client/threaded.rb
View
5 lib/zk/client/threaded.rb
@@ -156,7 +156,7 @@ def initialize(host, opts={}, &b)
tp_size = opts.fetch(:threadpool_size, DEFAULT_THREADPOOL_SIZE)
@threadpool = Threadpool.new(tp_size)
- @connection_timeout = opts.fetch(:timeout, DEFAULT_TIMEOUT) # maybe move this into superclass?
+ @connection_timeout = opts[:timeout] || DEFAULT_TIMEOUT # maybe move this into superclass?
@event_handler = EventHandler.new(self, opts)
@reconnect = opts.fetch(:reconnect, true)
@@ -244,6 +244,9 @@ def reopen(timeout=nil)
logger.debug { "reopening, no fork detected" }
@last_cnx_state = Zookeeper::ZOO_CONNECTING_STATE
+
+ timeout ||= @connection_timeout # or @connection_timeout here is the docuemnted behavior on Base#reopen
+
@cnx.reopen(timeout) # ok, we werent' forked, so just reopen
# this is a bit of a hack, because we need to wait until the event thread

0 comments on commit e28c430

Please sign in to comment.