avoid potential Logger deadlocks in signal handling
commit30ab37594677c12a4884d7199d808a8a28832549
authorEric Wong <normalperson@yhbt.net>
Wed, 31 Aug 2011 07:54:25 +0000 (31 07:54 +0000)
committerEric Wong <normalperson@yhbt.net>
Wed, 31 Aug 2011 07:54:25 +0000 (31 07:54 +0000)
tree8aacde5d461a4335a96cbb58ef543276f45c6f8f
parent8c3916bfe76224b69e0f20827c4230c4e71cdc86
avoid potential Logger deadlocks in signal handling

If any combination of signals are sent to Zbatery in a short
period of time, the Mutex used by the default Logger
implementation may deadlock since Mutex synchronization is not
reentrant-safe.

By spawning a thread, we can take advantage of the thread-safety
and avoid the reentrancy-safety issue of acquiring a mutex
inside a signal handler.

Users of alternative logger implementations (or monkey-patched
ones) are possibly not affected.  Users of the logger_mp_safe.rb
monkey-patch distributed[1] with unicorn are not affected.

[1] http://unicorn.bogomips.org/examples/logger_mp_safe.rb
lib/zbatery.rb