lib/zk/fork_hook.rb in zk-1.5.0 vs lib/zk/fork_hook.rb in zk-1.5.1
- old
+ new
@@ -14,25 +14,26 @@
attr_reader :hooks, :mutex
# @private
def fire_prepare_hooks!
@mutex.lock
+ logger.debug { "#{__method__}" }
safe_call(@hooks[:prepare])
end
# @private
def fire_after_child_hooks!
- safe_call(@hooks[:after_child])
- ensure
@mutex.unlock rescue nil
+ logger.debug { "#{__method__}" }
+ safe_call(@hooks[:after_child])
end
# @private
def fire_after_parent_hooks!
- safe_call(@hooks[:after_parent])
- ensure
@mutex.unlock rescue nil
+ logger.debug { "#{__method__}" }
+ safe_call(@hooks[:after_parent])
end
# @private
def clear!
@mutex.synchronize { @hooks.values(&:clear) }
@@ -50,19 +51,14 @@
#
# @private
def safe_call(callbacks)
cbs = callbacks.dup
+ # exceptions in these hooks will be raised normally
+
while cb = cbs.shift
- begin
- cb.call
- rescue WeakRef::RefError
- # clean weakrefs out of the original callback arrays if they're bad
- callbacks.delete(cb)
- rescue Exception => e
- logger.error { e.to_std_format }
- end
+ cb.call
end
end
# @private
def register(hook_type, block)
@@ -74,10 +70,10 @@
raise ArgumentError, "You must provide either a callable an argument or a block"
end
ForkSubscription.new(hook_type, block).tap do |sub|
# use a WeakRef so that the original objects can be GC'd
- @mutex.synchronize { @hooks[hook_type] << WeakRef.new(sub) }
+ @mutex.synchronize { @hooks[hook_type] << sub }
end
end
# Register a block that will be called in the parent process before a fork() occurs
def prepare_for_fork(callable=nil, &blk)