From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=-0.5 required=5.0 tests=AWL,MSGID_FROM_MTA_HEADER, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.unicorn.general Subject: Re: Strange quit behavior Date: Fri, 19 Aug 2011 22:18:44 +0000 Message-ID: <20110819221844.GA519@dcvr.yhbt.net> References: <20110802215335.GA11745@dcvr.yhbt.net> <20110803003449.GA8373@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1313793119 822 80.91.229.12 (19 Aug 2011 22:31:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 19 Aug 2011 22:31:59 +0000 (UTC) To: unicorn list Original-X-From: mongrel-unicorn-bounces@rubyforge.org Sat Aug 20 00:31:55 2011 Return-path: Envelope-to: gclrug-mongrel-unicorn@m.gmane.org X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org Content-Disposition: inline In-Reply-To: <20110803003449.GA8373@dcvr.yhbt.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: mongrel-unicorn@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org Xref: news.gmane.org gmane.comp.lang.ruby.unicorn.general:1122 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QuXbX-000148-7N for gclrug-mongrel-unicorn@m.gmane.org; Sat, 20 Aug 2011 00:31:55 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 61C9D158806B; Fri, 19 Aug 2011 18:31:52 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id F1A611858300 for ; Fri, 19 Aug 2011 18:18:44 -0400 (EDT) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 421B8211FF; Fri, 19 Aug 2011 22:18:44 +0000 (UTC) Eric Wong wrote: > Eric Wong wrote: > > If you SIGQUIT/SIGTERM before the app is loaded, the signal could > > be ignored. This behavior should probably change... > > I pushed the following to git://bogomips.org/unicorn > > From 406b8b0e2ed6e5be34d8ec3cd4b16048233c2856 Mon Sep 17 00:00:00 2001 > From: Eric Wong > Date: Tue, 2 Aug 2011 23:52:14 +0000 > Subject: [PATCH] trap death signals in the worker sooner > > This helps close a race condition preventing shutdown if > loading the application (preload_app=false) takes a long > time and the user decides to kil workers instead. The following completely eliminates the race condition: >>From 8de6ab371c1623669b86a5dfa8703c8fd539011f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 19 Aug 2011 22:13:04 +0000 Subject: [PATCH] close race if an exit signal hits the worker before trap The signal handler from the master is still active and will push the pending signal to SIG_QUEUE if a worker receives a signal immediately after forking. --- lib/unicorn/http_server.rb | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index aa8212e..4f516c9 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -549,6 +549,7 @@ class Unicorn::HttpServer def init_worker_process(worker) # we'll re-trap :QUIT later for graceful shutdown iff we accept clients EXIT_SIGS.each { |sig| trap(sig) { exit!(0) } } + exit!(0) if (SIG_QUEUE & EXIT_SIGS)[0] WORKER_QUEUE_SIGS.each { |sig| trap(sig, nil) } trap(:CHLD, 'DEFAULT') SIG_QUEUE.clear -- Eric Wong _______________________________________________ Unicorn mailing list - mongrel-unicorn@rubyforge.org http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying