httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael H. Voase" <>
Subject Re: [Fwd: mod_cgi and pthread problems] (fwd)
Date Tue, 02 Feb 1999 14:51:45 GMT
Ryan Bloom wrote:

> Michael,
> We can't use chdir directly.  We have another person right now, writing a
> spawn process for threaded-Apache.  The problem with using chdir directly,
> is that that will change the directory for the entire process, not the
> thread that calls it.  The proper solution, IMHO, is to collapse a lot of
> the forking code into spawn.  Spawn would need to be about five or six
> lines, that would fork, return on the parent process, and on the child
> process it would chdir, and exec the new program.

Forgive me if I have missed something here , that seems to be what its
doing now . The actual call to chdir is in the child process . I am
I am missing the point here somewhere . ap_bspawn_child is called
from cgi_handler that then returns immediately ( if all goes well ) and
continues on while cgi_child is called by ap_bspawn_child which forks()
the new process . It  then wanders off and sets up its env , does
the chdir and execs the script . much like what you have described
above ( almost to a tee ) ????

>  Taking care of memory
> and cleanups along the way.  The spawn function will also need to set-up
> the pipes between cgi's and the server.

Always important doing the cleanups . However , ap_bspawn_child does the
pipe hookups ...

> Windows does things very very
> differently, because their CreateProcess API allows them to just send in a
> current directory and handles to use for pipes.  UNIX isn't that nice to
> us.

Yes I am aware , windows is very different . Note that ap_bspawn_child
its current incarnation does actually pass these pipes as part of its
( script_in , script_out and script_err )

> Because of these differences, at some point, we need to write APR, which
> should hide these niggling points from common Apache developers.  That is
> on my list of things to do, but it will be a month or so before I get to
> it.

Agreed .

> The code path shouldn't be that long, I agree, and it shouldn't be hard to
> implement, but we are very driven to do this the right way the first time.
> Let us know if/when you implement the work.
> Ryan

Its just the point further up thats got me miffed . cgi_child
is the spawned process that becomes the script on the
exec .  If my multiprocess theory is steering me right
here  , the chdir is happenening in an independent
process which should not effect the rest of the threads
in apache . ( unless there is some magical way that a
forked process from a thread can affect  the parent process
that I am not aware of . AFAIK , the forked process should
be inheriting the globals from the parent as local copies  ....
but then again , only  a few hours ago I thought it was a no-no
to even call fork() from a thread )

Cheers Mik Voase.

 /~\     /~\            CASTLE INDUSTRIES PTY. LTD.
 | |_____| |            Incorporated 1969. in N.S.W., Australia
 |         |            Phone +612 6562 1345 Fax +612 6567 1449
 |   /~\   |            Web
 |   [ ]   |            Michael H. Voase.  Director.
~~~~~~~~~~~~~~          Cause Linux Flies and Windoze Dies ... 'nuf

View raw message