Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E383CCCB for ; Tue, 2 Dec 2014 08:10:23 +0000 (UTC) Received: (qmail 35148 invoked by uid 500); 2 Dec 2014 08:10:22 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 35091 invoked by uid 500); 2 Dec 2014 08:10:22 -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 35081 invoked by uid 99); 2 Dec 2014 08:10:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2014 08:10:22 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ylavic.dev@gmail.com designates 209.85.223.181 as permitted sender) Received: from [209.85.223.181] (HELO mail-ie0-f181.google.com) (209.85.223.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2014 08:09:56 +0000 Received: by mail-ie0-f181.google.com with SMTP id tp5so10767132ieb.26 for ; Tue, 02 Dec 2014 00:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=B6IP+QffK46QuknYM1Qc8a5z9GrrXLGwMUHBJsarCo0=; b=PSIOqY3HlRYZthKMKJVZgCLf//VXh2xy1vHQYQwj4/wU3W5UZuQ/sMyMXzLEMhOW/g uPi7i9z+PoslsDWyYOvsjL3KA6CWMR5WmTV8zCnk163I2tnqbojPFWhs3GYqYRCLPo4g ca61NENK3PE0Fvo8v2EJzjsloD7LL6Pqq8bYrRZo1QPO95aApeb3FZfteKL/xyV9w4F/ dq7XaQKwF4YSwZoE0g5dLaBu6Z8CM9Q86p6TL3rcWGRV3/CZSG+R+dRIY8KcOuCQLX2n f+ZicMsg1/w+rcsPz1Kk6XlOrRJumI1HxdIfchppXIBxQvc+wmHIpoU+uSW3/4D+WSCu F/AA== MIME-Version: 1.0 X-Received: by 10.107.40.16 with SMTP id o16mr10719749ioo.26.1417507794768; Tue, 02 Dec 2014 00:09:54 -0800 (PST) Received: by 10.42.255.7 with HTTP; Tue, 2 Dec 2014 00:09:54 -0800 (PST) In-Reply-To: <20141114120446.C8F0523888D2@eris.apache.org> References: <20141114120446.C8F0523888D2@eris.apache.org> Date: Tue, 2 Dec 2014 09:09:54 +0100 Message-ID: Subject: Re: svn commit: r1639614 - /httpd/httpd/trunk/server/mpm/event/event.c From: Yann Ylavic To: httpd Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Nov 14, 2014 at 1:04 PM, wrote: > Author: covener > Date: Fri Nov 14 12:04:46 2014 > New Revision: 1639614 > > URL: http://svn.apache.org/r1639614 > Log: > don't call notify_suspend() in a worker thread after > start_lingering_close_common may have put the socket back > into the pollset. > > If it becomes readable too quickly, cs can be > free'ed or accessed concurrently. > > Modified: > httpd/httpd/trunk/server/mpm/event/event.c > [] > +static int start_lingering_close_common(event_conn_state_t *cs, int in_worker) > { > apr_status_t rv; > struct timeout_queue *q; > @@ -849,6 +861,9 @@ static int start_lingering_close_common( > cs->pub.sense == CONN_SENSE_WANT_WRITE ? APR_POLLOUT : > APR_POLLIN) | APR_POLLHUP | APR_POLLERR; > cs->pub.sense = CONN_SENSE_DEFAULT; > + if (in_worker) { > + notify_suspend(cs); > + } Can't we put this outside the critical section? (should the hook take non negligible time). > rv = apr_pollset_add(event_pollset, &cs->pfd); > apr_thread_mutex_unlock(timeout_mutex); > if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) { Eg. Index: server/mpm/event/event.c =================================================================== --- server/mpm/event/event.c (revision 1642684) +++ server/mpm/event/event.c (working copy) @@ -859,16 +859,16 @@ static int start_lingering_close_common(event_conn cs->pub.state = CONN_STATE_LINGER_NORMAL; } apr_atomic_inc32(&lingering_count); + cs->c->sbh = NULL; + if (in_worker) { + notify_suspend(cs); + } apr_thread_mutex_lock(timeout_mutex); - cs->c->sbh = NULL; TO_QUEUE_APPEND(*q, cs); cs->pfd.reqevents = ( cs->pub.sense == CONN_SENSE_WANT_WRITE ? APR_POLLOUT : APR_POLLIN) | APR_POLLHUP | APR_POLLERR; cs->pub.sense = CONN_SENSE_DEFAULT; - if (in_worker) { - notify_suspend(cs); - } rv = apr_pollset_add(event_pollset, &cs->pfd); apr_thread_mutex_unlock(timeout_mutex); if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) { --