httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Douglass <miked...@texas.net>
Subject Re: Oh sod it
Date Wed, 26 Jun 1996 15:40:22 GMT
On Tue, 25 Jun 1996, Ben Laurie wrote:

> Of course, there is an interesting race condidition between where the signal
> is unblocked and the blocking system call, but I guess in we can live with it
> in this context (though I do have a cute fix if needed).

Wait a minute; I know I just posted with a suggestion/thought of using the
UNIX file system to sigal to the children to stop responding to requests and
die...  Then I had a thought.  I saw some of the code using shared memory
(or at least there was some patch that was using it) and I thought of
semaphores.  When the main server starts, create a semaphore set with two
semaphores.

sem0: number of children
sem1: die flag

Whenever a child starts, +1 to sem0.  When a child goes away -1 to sem0
(or use SEM_UNDO to do it automatically).  When the server wants the
children to die out gracefully raise sem1 to 1 (or drop it to 0--which
ever you want).  Before the children accept connections, check sem1, if
sem1 is telling them to exit then decrement sem0 and exit.  When the
server detects sem0 at 0 remove the semaphores and go on it's marry way.

In this way, you can signal the children to die; start up new children
with the new configuration and create a seperate semaphore set for the
new children.  In some idle processing area of the server have it check
old semaphore tables for existing children.  Perhaps after some default
timeout kill the resources (and children if pids are known).

I have not really looked at the code for apache all that much, and these
thoughts are coming from the general discussion only.

Michael Douglass
Texas Networking, Inc.

  "To be a saint is to be an exception; to be a true man is the rule.
   Err, fail, sin if you must, but be upright.  To sin as little as
   possible is the law for men; to sin not at all is a dream for angels."

              - Victor Hugo, "Les Miserables"


Mime
View raw message