From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: [PATCH] avoid potential Logger deadlock in SIGQUIT and SIGUSR1
Date: Tue, 30 Aug 2011 23:32:32 +0000 [thread overview]
Message-ID: <20110830233232.GA19633@dcvr.yhbt.net> (raw)
If any combination of SIGQUIT and SIGUSR1 are sent to a
Rainbows! worker in a /very/ short period of time, the Mutex
used by the default Logger implementation may deadlock since
Mutex synchronization is not reentrant-safe.
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
---
I've pushed to rainbows.git I haven't seen Rainbows! hit it,
but I've encountered this elsewhere.
I don't have anything else for a bit, so maybe I'll just
release 4.3.1 tonight. Anybody have any other outstanding issues?
lib/rainbows/base.rb | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb
index d1c5c08..54f1d2d 100644
--- a/lib/rainbows/base.rb
+++ b/lib/rainbows/base.rb
@@ -18,8 +18,11 @@ module Rainbows::Base
# we're don't use the self-pipe mechanism in the Rainbows! worker
# since we don't defer reopening logs
Rainbows::HttpServer::SELF_PIPE.each { |x| x.close }.clear
- trap(:USR1) { reopen_worker_logs(worker.nr) }
- trap(:QUIT) { Rainbows.quit! }
+
+ # spawn Threads since Logger takes a mutex by default and
+ # we can't safely lock a mutex in a signal handler
+ trap(:USR1) { Thread.new { reopen_worker_logs(worker.nr) } }
+ trap(:QUIT) { Thread.new { Rainbows.quit! } }
[:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
Rainbows::ProcessClient.const_set(:APP, Rainbows.server.app)
logger.info "Rainbows! #@use worker_connections=#@worker_connections"
--
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying
reply other threads:[~2011-08-31 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/rainbows/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110830233232.GA19633@dcvr.yhbt.net \
--to=normalperson-rmlxzr9ms24@public.gmane.org \
--cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/rainbows.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).