Return-Path: Delivered-To: apache-bugdb-archive@hyperreal.org Received: (qmail 25877 invoked by uid 6000); 25 Jan 2000 06:10:09 -0000 Received: (qmail 25759 invoked from network); 25 Jan 2000 06:10:02 -0000 Received: from unknown (HELO locus.apache.org) (63.211.145.10) by taz.hyperreal.org with SMTP; 25 Jan 2000 06:10:01 -0000 Received: (qmail 39089 invoked by uid 501); 25 Jan 2000 06:10:00 -0000 Received: (qmail 37622 invoked by uid 65534); 25 Jan 2000 06:00:02 -0000 Message-Id: <20000125060002.37621.qmail@locus.apache.org> Date: 25 Jan 2000 06:00:02 -0000 From: Craig Soules Reply-To: csoules@intraactive.com To: submit@bugz.apache.org X-Send-Pr-Version: 3.110 Subject: apache-api/5639: Global variables unavailable due to fork() Sender: apache-bugdb-owner@apache.org Precedence: bulk >Number: 5639 >Category: apache-api >Synopsis: Global variables unavailable due to fork() >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Mon Jan 24 22:10:00 PST 2000 >Closed-Date: >Last-Modified: >Originator: csoules@intraactive.com >Release: 1.3.9 (although most likely all versions) >Organization: apache >Environment: Linux 2.2.14, egcs-2.91.66, i686 >Description: I'm not quite sure this is a bug, so much as a flaw, but I would at least like to see this documented somewhere on your site. The main problem is that when writing a module in C with the API, the module can have no globally modifiable data, since the different server threads are created using standard fork() rather than a shared fork, or pthreads. This makes it impossible to keep any global state that can be modified on the fly (for example a database connection cache, or site configuration information in memory) Please, please at least document this somewhere. Thank you for your time. Craig Soules csoules@intraactive.com >How-To-Repeat: Yes. simply write a module that uses a global variable, set it to 0 in the init function, and then have the handler set the variable to a random number and never reset it. The numbers will be different, depending upon which server thread handles your request. >Fix: Either use pthreads, or clone() under linux, rather than fork/vfork. >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]