Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 7940 invoked from network); 30 Oct 2009 02:07:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Oct 2009 02:07:52 -0000 Received: (qmail 2161 invoked by uid 500); 30 Oct 2009 02:07:51 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 2080 invoked by uid 500); 30 Oct 2009 02:07:51 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 2068 invoked by uid 99); 30 Oct 2009 02:07:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2009 02:07:51 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bojan@rexursive.com designates 150.101.121.179 as permitted sender) Received: from [150.101.121.179] (HELO beauty.rexursive.com) (150.101.121.179) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2009 02:07:43 +0000 Received: from [10.1.120.24] (shrek.rexursive.com [10.1.120.24]) by beauty.rexursive.com (Postfix) with ESMTP id 13F518C172 for ; Fri, 30 Oct 2009 13:07:20 +1100 (EST) Subject: Re: worker MPM: close_worker_sockets race? From: Bojan Smojver To: dev@httpd.apache.org In-Reply-To: <1256253140.9540.33.camel@shrek.rexursive.com> References: <1256173732.9540.23.camel@shrek.rexursive.com> <1256245093.9540.31.camel@shrek.rexursive.com> <1256253140.9540.33.camel@shrek.rexursive.com> Content-Type: text/plain Date: Fri, 30 Oct 2009 13:07:19 +1100 Message-Id: <1256868439.2488.21.camel@shrek.rexursive.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Fri, 2009-10-23 at 10:12 +1100, Bojan Smojver wrote: > Slower, but safer attached (not even compiled, so could be utterly > bogus). BTW, this approach still isn't safe. The socket can disappear (i.e. be closed) between the test and the closing (or shutdown()). Worse, with shutdown(), we could attempt to shut down the wrong FD, if we have fast succession of close()/open() in various threads. I think the correct approach would be to make sure that we actually suspend worker threads before we do this. In other words, we send a signal to each worker thread and their signal handler calls sigsuspend(), thus waiting to be resumed. We also set thread specific variables, notifying the listener thread about workers that have been suspended. Once the listener thread knows this (i.e. that all workers are suspended), it shuts the sockets down and resumes the worker threads by sending them a signal. Workable? -- Bojan