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 877D47B8B for ; Mon, 1 Aug 2011 23:33:06 +0000 (UTC) Received: (qmail 76885 invoked by uid 500); 1 Aug 2011 23:33:06 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 76815 invoked by uid 500); 1 Aug 2011 23:33:05 -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 76807 invoked by uid 99); 1 Aug 2011 23:33:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 23:33:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [160.78.48.72] (HELO paulista.cce.unipr.it) (160.78.48.72) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 23:32:57 +0000 Received: from paulista.cce.unipr.it (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 3588E1EA0206 for ; Tue, 2 Aug 2011 01:32:35 +0200 (CEST) Received: from evoluzione.cce.unipr.it (evoluzione.biol.unipr.it [160.78.46.170]) by paulista.cce.unipr.it (Postfix) with ESMTP id AC7431EA01F6 for ; Tue, 2 Aug 2011 01:32:34 +0200 (CEST) Received: from www.biol.unipr.it (localhost [127.0.0.1]) by evoluzione.cce.unipr.it (Postfix) with ESMTP id 57D8A33E60D for ; Tue, 2 Aug 2011 01:34:08 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 02 Aug 2011 00:34:08 +0100 From: Massimo Manghi To: Subject: threads caveats working with 'worker' mpm Organization: =?UTF-8?Q?Universit=C3=A0_di_Parma?= Message-ID: X-Sender: massimo.manghi@unipr.it User-Agent: Roundcube Webmail/0.5.3 Hi I'm in the process of figuring out if mod_rivet could fit into an Apache http server using 'worker' as mpm. Rivet embeds Tcl in Apache and enables server side scripting using the Tcl language in pretty the same style you can do using PHP, for instance. I don't even know if this is possible as the big PHP itself for long time used to work only with a prefork server (and maybe still does...), but having threads could be a plus on heavily loaded servers and on certain architectures. So here I am... I tried an empiric approach, recompiling both Apache and Rivet with 'worker' as mpm and with debugging symbols, just to see what's going one in a threaded server. I assumed that basically threads would take the role that used to be a child's role with prefork. Instead it seems that threads are managed following a different logic: apparently threads are created when a request comes and their number seems not to be restricted by the parameter ThreadsPerChild (I set it as 2) The module seems to work (it logs data) but eventually it's unable to send data down the connection, most likely because the Tcl interpreter gets spoiled somehow (shouldn't just one thread be running if I have a single request being served?) I'm puzzled. Googling the subject didn't add more to what I already knew, so my questions are: - is the a general paper about the worker mpm as seen from the developer perspective? - Apart the usual caveats of accessing global/shared data after a Mutex lock has been gained, what a module is supposed to do in order to handle threads properly? Nick once said modules must be mpm agnostic as much as possible. Maybe it must be read as "module must be mpm agnostic if they can?" - How a child process can setup a thread environment and its private data? I apologize for the lengthy message. Thank you if you have read it up to the bottom line -- Massimo