httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy T. Fielding" <field...@kiwi.ICS.UCI.EDU>
Subject Re: [PATCH] murderous HUP
Date Tue, 18 Feb 1997 16:11:57 GMT
Marc Slemko writes:
>--- 1030,1086 ----
>      for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
>  	int pid = scoreboard_image->servers[i].pid;
>  
>! 	if (pid != my_pid && pid != 0) { 
>! 	    int waitret = 0,
>! 		tries = 1;
>! 
>! 	    while (waitret == 0 && tries <= 4) {
>! 		int waittime = 1; /* in usecs */
>! 		struct timeval tv;

Ummm, there is no point in waiting for any less than 1000 usecs, since
that's about how long it takes to execute a single instruction on a
reasonably fast machine.  I suggest starting with 4096 and *8 on each pass.
We don't want process swapping to steal all execution time from the children.

>! 		/* don't want to hold up progress any more than 
>! 		 * necessary, so keep checking to see if the child
>! 		 * has exited with an exponential backoff.
>! 		 * Currently set for a maximum wait of a bit over
>! 		 * four seconds.
>! 		 */
>! 		while (((waitret = waitpid(pid, &status, WNOHANG)) == 0) &&
>! 			 waittime < 3000000) {
>! 		       tv.tv_sec = waittime / 1000000;
>! 		       tv.tv_usec = waittime % 1000000;
>! 		       waittime = waittime * 2;
>! 		       select(0, NULL, NULL, NULL, &tv);
>! 		}

What I would suggest is

                long waittime = 4096;

                while (((waitret = waitpid(pid, &status, WNOHANG)) == 0) &&
                        (waittime > 0) && (waittime < 3000000)) {
                       tv.tv_sec  = 0;
                       tv.tv_usec = waittime;
                       waittime << 3;
                       select(0, NULL, NULL, NULL, &tv);
                }


The rest looks fine.

.....Roy

Mime
View raw message