httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralf Mattes ...@seid-online.de>
Subject Re: Apache modification questions
Date Fri, 05 Sep 2008 09:59:44 GMT
On Fri, 2008-09-05 at 18:49 +0900, Andrej van der Zee wrote:
> Hi,
> 
> >
> > A CGI script is run by the code of a module, mod_perl, mod_php5, etc.
> > In their register_hooks function they register their handler, which is
> > a script interpreter basically. The handler callback is invoked in the
> > same thread that did the rest of the request processing (URL parsing,
> > authentication, fixups, etc). 

I think there seems to be a confusion about terminology here: a
CGI-script by definition runs in its own process, _not_ within the
process address space of the webserver (hence the need for a defined 
"Common Gateway Interface" to pass request information to the external
application. See http://en.wikipedia.org/wiki/Common_Gateway_Interface).
Now, since the forking/spanwing is a rather time consuming operation
there are embedded interpreters for most of the commons scripting
languages (like perl/python etc.). Those often have a compatibility
layer to run unmodified CGI code within the webservers address/process
space (with sometimes strage side efects :-/).
 
> However, I don't know if the handler
> > callback (of mod_perl, mod_php5, etc), which can be seen as a sort of
> > third-party black box, spawns new processes/threads in which they
> > parse the script, compile, etc. I guess they do not spawn new
> > threads/processes but you have to read their docs or their sources in
> > order to be sure. If they do not spawn new threads/processes, then the
> > CGI is executed in the same thread as fixups and the rest of the
> > request processing.
> >
> 
> Thanks that makes sense.
> 
> If understood correctly, this means that I can add my own module to
> the chain of request processors that executes in the same thread as
> the hook function in mod_php5/mod_perl that executes CGI scripts.

For the embedded interpreters that's true.

> Though, if the module's hook function spawns a new process/thread for
> handling the CGI script is dependent on the module.

CGIs are handled by mod_cgi.

> Does anybody know if the hook functions of such modules usually
> spawning a new thread/process? My guess is that at least for compiled
> CGI application written in C/C++ a new process is forked in the hook
> function.

Iff those are real CGIs (applications) that's true.

 HTH Ralf Mattes

> Cheers,
> Andrej
> 
> 


Mime
View raw message