From: Ryan Bloom Date: Fri, 19 May 2000 01:05:26 +0000 (+0000) Subject: Move wait_or_timeout from the MPM's into the new mpm_common.c file. I X-Git-Tag: APACHE_2_0_ALPHA_4~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c065c115807b203ef1bbf1d8d6c987c11cf09928;p=apache Move wait_or_timeout from the MPM's into the new mpm_common.c file. I also renamed wait_or_timeout to ap_wait_or_timeout for namespace protection. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85250 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index 3876ead6ce..fb07fb1c6c 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -180,42 +180,6 @@ static void clean_child_exit(int code) exit(code); } -/* Finally, this routine is used by the caretaker process to wait for - * a while... - */ - -/* number of calls to wait_or_timeout between writable probes */ -#ifndef INTERVAL_OF_WRITABLE_PROBES -#define INTERVAL_OF_WRITABLE_PROBES 10 -#endif -static int wait_or_timeout_counter; - -static ap_proc_t *wait_or_timeout(ap_wait_t *status, ap_pool_t *p) -{ - struct timeval tv; - ap_status_t rv; - ap_proc_t *ret = NULL; - - ++wait_or_timeout_counter; - if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { - wait_or_timeout_counter = 0; -#ifdef APR_HAS_OTHER_CHILD - ap_probe_writable_fds(); -#endif - } - rv = ap_wait_all_procs(&ret, status, APR_NOWAIT, p); - if (ap_canonical_error(rv) == APR_EINTR) { - return NULL; - } - if (rv == APR_CHILD_DONE) { - return ret; - } - tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000; - tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000; - ap_select(0, NULL, NULL, NULL, &tv); - return NULL; -} - /* handle all varieties of core dumping signals */ static void sig_coredump(int sig) { @@ -1014,7 +978,7 @@ static void server_main_loop(int remaining_children_to_start) int i; while (!restart_pending && !shutdown_pending) { - pid = wait_or_timeout(&status, pconf); + pid = ap_wait_or_timeout(&status, pconf); if (pid != NULL) { int actual_pid; diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index 7cef3c8cb6..e8f1bf7cce 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -184,47 +184,6 @@ void clean_child_exit(int code) exit(code); } -/* Finally, this routine is used by the caretaker process to wait for - * a while... - */ - -/* number of calls to wait_or_timeout between writable probes */ -#ifndef INTERVAL_OF_WRITABLE_PROBES -#define INTERVAL_OF_WRITABLE_PROBES 10 -#endif -static int wait_or_timeout_counter; - -static ap_proc_t *wait_or_timeout(ap_wait_t *status, ap_pool_t *p) -{ - struct timeval tv; - ap_status_t rv; - ap_proc_t *ret = NULL; - - ++wait_or_timeout_counter; - if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { - wait_or_timeout_counter = 0; -#ifdef APR_HAS_OTHER_CHILD - ap_probe_writable_fds(); -#endif - } - rv = ap_wait_all_procs(&ret, status, APR_NOWAIT, p); - if (ap_canonical_error(rv) == APR_EINTR) { - return NULL; - } - if (rv == APR_CHILD_DONE) { - return ret; - } -#ifdef NEED_WAITPID - if ((ret = reap_children(status)) > 0) { - return ret; - } -#endif - tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000; - tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000; - ap_select(0, NULL, NULL, NULL, &tv); - return NULL; -} - /* handle all varieties of core dumping signals */ static void sig_coredump(int sig) { @@ -1061,7 +1020,7 @@ static void server_main_loop(int remaining_children_to_start) while (!restart_pending && !shutdown_pending) { /* this is a memory leak, but I'll fix it later. */ - pid = wait_or_timeout(&status, pconf); + pid = ap_wait_or_timeout(&status, pconf); if (pid != NULL) { process_child_status(pid, status); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index e7bb515962..458a252579 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1051,47 +1051,6 @@ int reap_children(ap_wait_t *status) } #endif -/* Finally, this routine is used by the caretaker process to wait for - * a while... - */ - -/* number of calls to wait_or_timeout between writable probes */ -#ifndef INTERVAL_OF_WRITABLE_PROBES -#define INTERVAL_OF_WRITABLE_PROBES 10 -#endif -static int wait_or_timeout_counter; - -static ap_proc_t *wait_or_timeout(ap_wait_t *status, ap_pool_t *p) -{ - struct timeval tv; - ap_status_t rv; - ap_proc_t *ret = NULL; - - ++wait_or_timeout_counter; - if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { - wait_or_timeout_counter = 0; -#ifdef APR_HAS_OTHER_CHILD - ap_probe_writable_fds(); -#endif - } - rv = ap_wait_all_procs(&ret, status, APR_NOWAIT, p); - if (ap_canonical_error(rv) == APR_EINTR) { - return NULL; - } - if (rv == APR_CHILD_DONE) { - return ret; - } -#ifdef NEED_WAITPID - if ((ret = reap_children(status)) > 0) { - return ret; - } -#endif - tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000; - tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000; - ap_select(0, NULL, NULL, NULL, &tv); - return NULL; -} - /* handle all varieties of core dumping signals */ static void sig_coredump(int sig) { @@ -2000,7 +1959,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) int child_slot; ap_wait_t status; /* this is a memory leak, but I'll fix it later. */ - ap_proc_t *pid = wait_or_timeout(&status, pconf); + ap_proc_t *pid = ap_wait_or_timeout(&status, pconf); /* XXX: if it takes longer than 1 second for all our children * to start up and get into IDLE state then we may spawn an diff --git a/server/mpm_common.c b/server/mpm_common.c index 3201b4c72b..a9663c3d91 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -167,4 +167,41 @@ void ap_reclaim_child_processes(int terminate) } } +/* number of calls to wait_or_timeout between writable probes */ +#ifndef INTERVAL_OF_WRITABLE_PROBES +#define INTERVAL_OF_WRITABLE_PROBES 10 +#endif +static int wait_or_timeout_counter; + +static ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p) +{ + struct timeval tv; + ap_status_t rv; + ap_proc_t *ret = NULL; + + ++wait_or_timeout_counter; + if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { + wait_or_timeout_counter = 0; +#ifdef APR_HAS_OTHER_CHILD + ap_probe_writable_fds(); +#endif + } + rv = ap_wait_all_procs(&ret, status, APR_NOWAIT, p); + if (ap_canonical_error(rv) == APR_EINTR) { + return NULL; + } + if (rv == APR_CHILD_DONE) { + return ret; + } +#ifdef NEED_WAITPID + if ((ret = reap_children(status)) > 0) { + return ret; + } +#endif + tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000; + tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000; + ap_select(0, NULL, NULL, NULL, &tv); + return NULL; +} +