Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7D3AF10AE3 for ; Wed, 12 Jun 2013 09:49:38 +0000 (UTC) Received: (qmail 92279 invoked by uid 500); 12 Jun 2013 09:49:35 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 92248 invoked by uid 500); 12 Jun 2013 09:49:33 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 92237 invoked by uid 99); 12 Jun 2013 09:49:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jun 2013 09:49:32 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alex@alex.org.uk designates 89.16.176.221 as permitted sender) Received: from [89.16.176.221] (HELO mail.avalus.com) (89.16.176.221) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jun 2013 09:49:26 +0000 Received: by mail.avalus.com (Postfix) with ESMTPSA id 70FE9C5603D; Wed, 12 Jun 2013 10:48:55 +0100 (BST) Subject: Re: Mutex protection of output bucket brigade Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Alex Bligh In-Reply-To: <51B83D4F.60401@gmail.com> Date: Wed, 12 Jun 2013 10:48:54 +0100 Cc: Alex Bligh Content-Transfer-Encoding: quoted-printable Message-Id: <8791D980-E089-428D-8A0F-F25343BB8508@alex.org.uk> References: <2EA9BCBC-E052-41C5-B3DE-1222FE2A6BAD@alex.org.uk> <51B83D4F.60401@gmail.com> To: modules-dev@httpd.apache.org X-Mailer: Apple Mail (2.1085) X-Virus-Checked: Checked by ClamAV on apache.org On 12 Jun 2013, at 10:20, Sorin Manolache wrote: > If I understand correctly, the main thread belongs to your module, = i.e. it is not a concise pseudo-code of the request processing in = apache's code. The main thread is the (presumably single) thread of the prefork mpm = process, created (I assume) by a fork() in apache's worker code. The pseudo code was what my long-running request handler does (after = creating the other thread). IE, broadly speaking my request handler (the = main thread if you like) does this: apr_thread_create; /* create the spawned thread */ while (!done) { /* Blocking read */ apr_brigade_create; ap_get_brigade; apr_brigade_flatten; /* Do stuff with the data */ blocking_socket_write; } apr_thread_join; /* wait until the spawned thread has executed */ > I don't see where the output brigade appears in the main thread. I = think this is critical, as the output_bucket_brigade is the data item = shared between the two threads. ap_get_brigade triggers the execution of = the chain of input filters. One of these input filters writes to the = output brigade? ap_get_brigade is called with APR_BLOCK_READ. What I now /believe/ this does (because it's the only way data would = actually get written) is write the post processed output bucket brigade = to the client too. If this were not the case, it's difficult to see how = a single threaded application would every write the output bucket = brigade. Or are you saying the output bucket brigade is only actually written to = the client during an ap_fwrite()? In which case are all the filters = (primarily mod_ssl) guaranteed to be thread safe if a different thread = is doing input from that doing output? --=20 Alex Bligh