You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@gmail.com> on 2004/10/07 21:27:19 UTC

Re: Bug: Apache hangs if script invokes fork/waitpid

On Wed, 6 Oct 2004 11:01:23 -0700, Naik, Roshan <ro...@hp.com> wrote:
> The Problem:
> ---------------
> I notice Apache 2(worker mpm) is not able to correctly handle
> a fork/waitpid invoked by a script used with mod_perl.

>From Ulrich Drepper: "No threaded programs must use anything but _exit
or exec after fork."
Perhaps a tiny bit harsh?

What if you fork a copy of a mutex used by some third-party Apache
module?  That module would need to be using pthread_atfork() to make
sure ownership is preserved properly.  Apache/APR certainly doesn't do
it with its mutexes.

I think there needs to be a mod_fork which provides a more general
purpose daemon than that used by mod_cgid, and some Apache API will
know whether or not to send a request over there.  This preserves the
goal of having fork() called only by single-threaded processes so that
all manner of pain is avoided.

Re: Bug: Apache hangs if script invokes fork/waitpid

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, 07 Oct 2004 12:53:47 -0700, Paul Querna <ch...@force-elite.com> wrote:
> Jeff Trawick wrote:
> > I think there needs to be a mod_fork which provides a more general
> > purpose daemon than that used by mod_cgid, and some Apache API will
> > know whether or not to send a request over there.  This preserves the
> > goal of having fork() called only by single-threaded processes so that
> > all manner of pain is avoided.
> 
> Big +1 from me in concept.
> 
> I am not sure how to do the implementation best.  mod_cgid doesn't
> really 'fork' in the sense most programs do, its mostly just starting up
> a cgi process -- from an executable on the file system.
> 
> This seems drastically different from the requirements of a generic fork().
> 
> Any thoughts on how you would want to implement this in a generic manner
> for any call from anywhere for any module?

it has to be extremely restricted; the obvious capability is to allow
apr_proc_create() to be called, with pipes set up properly back to
code running in the Apache thread; another possible service is to
allow a new child to be created and then in that process call some
specified function which was copied into the mod_fork daemon process
at apache startup; maybe that code happens to be some part of mod_perl
which can implement suitable services on behalf of a perl script

I suspect that whatever restrictions on applications are necessary to
implement such a service are the same restrictions which must be
respected anyway in order to have an application which works
reliably+portably in a threaded MPM.

Re: Bug: Apache hangs if script invokes fork/waitpid

Posted by Paul Querna <ch...@force-elite.com>.
Jeff Trawick wrote:
> I think there needs to be a mod_fork which provides a more general
> purpose daemon than that used by mod_cgid, and some Apache API will
> know whether or not to send a request over there.  This preserves the
> goal of having fork() called only by single-threaded processes so that
> all manner of pain is avoided.

Big +1 from me in concept.

I am not sure how to do the implementation best.  mod_cgid doesn't 
really 'fork' in the sense most programs do, its mostly just starting up 
a cgi process -- from an executable on the file system.

This seems drastically different from the requirements of a generic fork().

Any thoughts on how you would want to implement this in a generic manner 
for any call from anywhere for any module?

-Paul Querna