httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Naik, Roshan" <roshan.n...@hp.com>
Subject RE: Bug: Apache hangs if script invokes fork/waitpid
Date Wed, 13 Oct 2004 19:26:21 GMT
 

> -----Original Message-----
> From: Rüdiger Plüm [mailto:r.pluem@t-online.de] 
> Sent: Tuesday, October 12, 2004 2:45 PM
> To: dev@httpd.apache.org
> Subject: Re: Bug: Apache hangs if script invokes fork/waitpid
> 
> [..cut..]
>
> I think 1. is the "problem" in our case. If you do a fork in 
> your perl script you simply create another Apache process 
> where your forked perl script is running inside. After the 
> forked part of the script has finished its job mod_perl will 
> be left and the Apache process will continue doing its normal 
> "designed" work: Waiting for the next request.

I would prefer not to call it as "designed to work". It seems
like this situation was not taken into considertaion in the design.
Atleast I don't believe it was designed deliberately so that it would 
hang.


> This behaviour should be totally independent from the MPM you use.

Yes, ideally it should. I am not sure if it is the case though.

> So I think mod_perl needs to provide some kind of wrapper for 
> the fork command that does the needed cleanups just before 
> the real fork is done (as other modules in Apache do that 
> fork processes) and that will terminate the process as soon 
> as the user provided perl code of this forked process is 
> left. So the behaviour will differ from the normal mod_perl 
> behaviour (giving control back to the Apache process / thread).
> 

It is not a mod_perl specific problem. It is a problem with any module
like mod_perl. That is a script executed by this module can invoke fork().

You see it is not appropriate to handle this situation in mod_perl. For the
following reasons:

 - mod_perl doesn't really know that the scipt called mod_perl. It hands off the
   script to Perl to interpret and execute. So it is Perl who is acutally calling
   fork()...not mod_perl

 - This means mod_perl needs to know too much about the Apache's internal working. 
   As to whether it should call pthread_exit() or exit() is dependent on the MPM.

 - Secondly mod_perl's decision to terminate could be premature.... it doesn't give 
   apache any chance to perform any clean ups and other things(if needed).

 - In general the decision to exit a proram should not be buried deep in a function call
   stack. This decision should be pushde out the highest level possible ... ideally main().
   
-Roshan


Mime
View raw message