From: Manoj Kasichainula Date: Thu, 11 Nov 1999 22:57:19 +0000 (+0000) Subject: Fix a race condition found by David Colasurdo . We X-Git-Tag: 1.3.10~175 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3e874f7e9dd83e1835369a22e59b1db948ec88f;p=apache Fix a race condition found by David Colasurdo . We should make sure that the parent notes the creation of a child process in the scoreboard so that perform_idle_server_maintanence doesn't get the chance to claim that slot. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84116 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index dddb9ca854..383724dc51 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -1028,8 +1028,18 @@ static int make_child(server_rec *s, int slot, time_t now) /* ZZZ */ child_main(slot); } + /* Tag this slot as occupied so that perform_idle_server_maintenance + * doesn't try to steal it */ + (void) ap_update_child_status(slot, 0, SERVER_STARTING, (request_rec *) NULL); + if ((pid = fork()) == -1) { ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process"); + + /* fork didn't succeed. Fix the scoreboard or else + * it will say SERVER_STARTING forever and ever + */ + (void) ap_update_child_status(slot, 0, SERVER_DEAD, (request_rec *) NULL); + /* In case system resources are maxxed out, we don't want Apache running away with the CPU trying to fork over and over and over again. */