lib/zk/locker/shared_locker.rb in zk-1.7.1 vs lib/zk/locker/shared_locker.rb in zk-1.7.2

- old
+ new

@@ -89,15 +89,14 @@ if got_read_lock? @mutex.synchronize { @locked = true } elsif lock_opts.blocking? block_until_read_lock!(:timeout => lock_opts.timeout) else - # we didn't get the lock, and we're not gonna wait around for it, so - # clean up after ourselves - cleanup_lock_path! false end + ensure + cleanup_lock_path! unless @mutex.synchronize { @locked } end def block_until_read_lock!(opts={}) begin path = "#{root_lock_path}/#{next_lowest_write_lock_name}" @@ -107,15 +106,9 @@ @node_deletion_watcher = NodeDeletionWatcher.new(zk, path) @cond.broadcast end @node_deletion_watcher.block_until_deleted(opts) - rescue ZK::Exceptions::LockWaitTimeoutError - # in the case of a timeout exception, we need to ensure the lock - # path is cleaned up, since we're not interested in acquisition - # anymore - cleanup_lock_path! - raise rescue NoWriteLockFoundException # next_lowest_write_lock_name may raise NoWriteLockFoundException, # which means we should not block as we have the lock (there is nothing to wait for) end