httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@ai.mit.edu (Robert S. Thau)
Subject Re: feature idea
Date Sun, 09 Jun 1996 00:03:26 GMT
  The easiest way to do this appears (to me) to add a flag to short_score.
  The main server sets the flag on receipt of a signal.  The child process
  checks it when returning from the select call.

Ummm... hate to dampen your enthusiasm, but (unless I'm screwing up again),
it would be *quite* a bit easier to make the child-server SIGHUP handler
set a flag like so:

  static int time_to_die = 0;

  static void time_for_graceful_death () { time_to_die = 1; }

and to have the child process check time_to_die at the same time it
currently checks the scoreboard at the top of the loop in child_main.
(This relies on the parent process's current behavior of doing a 
killpg with SIGHUP when it receives one itself --- but as I've said
before, signal numbers are irrelevant):

	if ((count_idle_servers() >= daemons_max_free)
	    || time_to_die
	    || (max_requests_per_child > 0
	        && ++requests_this_child >= max_requests_per_child))
	{
	    exit(0);
	}

To activate this, you'd need to have the flag setter installed as the
SIGHUP handler in make_child instead of the current instant-death
just_die routine:

    if (!pid) {
	signal (SIGHUP, (void (*)()) time_for_graceful_death);
        signal (SIGTERM, (void (*)()) just_die);
        child_main (child_num);
    }

This sort of thing strikes me, at least, as a whole lot nicer than
messing with the scoreboard.  (There are some details --- it might
be good to get it to drop persistent connections early if time_to_die
is set --- but that isn't hard, and doing things through the scoreboard
would not, IMHO, make it any easier). 

rst

Mime
View raw message