httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <>
Subject Re: [PATCH] pool confusion (take 1)
Date Mon, 10 Nov 1997 06:15:55 GMT
On Sun, 9 Nov 1997, Dean Gaudet wrote:

> The current code has two related bugs:
>     - flock doesn't seem to be cleaning up its file on
> 	SIGTERM under Linux
>     - the register_other_child API is getting "unregister"
> 	events when it shouldn't (this one is on the STATUS already)
> They're related because what's happened is that all httpd children are
> calling destroy_pool(pconf).  This is wrong.
> Alexei added this when he was fixing up the child_exit API in August, you
> can read that thread if you want to know what he did... but he made the
> children start calling destroy_pool(pconf) claiming it was the right thing
> to do.  I'm now claiming it's not the right thing to do.

Not in the instance you're reffering to, no. But it is sometimes a
good idea. To see why, recall what happens when a process forks in
Unix (and this isn't really my area of expertise, so if I make a
mistake, please let me know). Basically, the memory segment occupied
by the process is copied, byte for byte, into a new process, and then
control is returned to each process, with some indication of which
process they are. Things that are internal to the process, like
memory, there are now two copies of. Things that are external, like
file handles (which are really just numbers that mean something to the
system) are not.

In other words, it's sort of like what would happen if I cloned you
(and I mean the "stick you in a Xerox machine" type of clone that one
finds in movies, not the biological type of clone). Each of you has
your own liver, your own legs, your own brain, which are identical but
completely independent. However, you both have the same house, the
same car, the same driver's license number.

What I'm trying to point out is this: Let's say the main server does a
pregcomp() with pconf as the pool. This sets up a cleanup in pconf to
get rid of the regex once it's done with (it calls free()). Now, if
the main server now spawns a child, that child should certainly want
to call that cleanup, since it now has its own copy of the memory
that's being freed.

Admittedly, the subsequent exit() does get rid of the said memory, but
this is the only example I can think of off the top of my head.

I am convinced, however, that it is neccessary in some cases.

-- Alexei Kosut <>

View raw message