From: Aaron Bannert Date: Tue, 29 Jan 2002 02:41:46 +0000 (+0000) Subject: Take advantage of the new pre_config return value when apr_proc_detach X-Git-Tag: 2.0.31~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa71fe9345f6e04345d00ecd1104787cd8f75884;p=apache Take advantage of the new pre_config return value when apr_proc_detach fails. I'll be making some changes to apr_proc_detach, and it will be nice to be able to report runtime errors. Tested on worker but the code changes are identical on other MPMs. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93069 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/beos/beos.c b/server/mpm/beos/beos.c index 2f059eae21..b618e364af 100644 --- a/server/mpm/beos/beos.c +++ b/server/mpm/beos/beos.c @@ -996,6 +996,7 @@ static int beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem { static int restart_num = 0; int no_detach, debug; + apr_status_t rv; debug = ap_exists_config_define("DEBUG"); @@ -1011,8 +1012,14 @@ static int beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem if (restart_num++ == 1) { is_graceful = 0; - if (!one_process && !no_detach) - apr_proc_detach(); + if (!one_process && !no_detach) { + rv = apr_proc_detach(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "apr_proc_detach failed"); + return HTTP_INTERNAL_SERVER_ERROR; + } + } server_pid = getpid(); } diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c index 5bf52b9465..ddc947f004 100644 --- a/server/mpm/experimental/perchild/perchild.c +++ b/server/mpm/experimental/perchild/perchild.c @@ -1432,6 +1432,7 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem int i; int tmp_server_limit = DEFAULT_SERVER_LIMIT; int tmp_thread_limit = DEFAULT_THREAD_LIMIT; + apr_status_t rv; debug = ap_exists_config_define("DEBUG"); @@ -1448,7 +1449,12 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem is_graceful = 0; if (!one_process && !no_detach) { - apr_proc_detach(); + rv = apr_proc_detach(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "apr_proc_detach failed"); + return HTTP_INTERNAL_SERVER_ERROR; + } } my_pid = getpid(); diff --git a/server/mpm/perchild/perchild.c b/server/mpm/perchild/perchild.c index 5bf52b9465..ddc947f004 100644 --- a/server/mpm/perchild/perchild.c +++ b/server/mpm/perchild/perchild.c @@ -1432,6 +1432,7 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem int i; int tmp_server_limit = DEFAULT_SERVER_LIMIT; int tmp_thread_limit = DEFAULT_THREAD_LIMIT; + apr_status_t rv; debug = ap_exists_config_define("DEBUG"); @@ -1448,7 +1449,12 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem is_graceful = 0; if (!one_process && !no_detach) { - apr_proc_detach(); + rv = apr_proc_detach(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "apr_proc_detach failed"); + return HTTP_INTERNAL_SERVER_ERROR; + } } my_pid = getpid(); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 42e1fd9c0c..b55bbe4602 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1204,6 +1204,7 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp { static int restart_num = 0; int no_detach, debug; + apr_status_t rv; debug = ap_exists_config_define("DEBUG"); @@ -1219,9 +1220,14 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp if (restart_num++ == 1) { is_graceful = 0; - if (!one_process && !no_detach) { - apr_proc_detach(); - } + if (!one_process && !no_detach) { + rv = apr_proc_detach(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "apr_proc_detach failed"); + return HTTP_INTERNAL_SERVER_ERROR; + } + } parent_pid = ap_my_pid = getpid(); } diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 1b23c65048..fdf9cafa49 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -1541,12 +1541,13 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) } static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, - apr_pool_t *ptemp) + apr_pool_t *ptemp) { static int restart_num = 0; int no_detach, debug; ap_directive_t *pdir; ap_directive_t *max_clients = NULL; + apr_status_t rv; /* make sure that "ThreadsPerChild" gets set before "MaxClients" */ for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) { @@ -1599,7 +1600,12 @@ static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, is_graceful = 0; if (!one_process && !no_detach) { - apr_proc_detach(); + rv = apr_proc_detach(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "apr_proc_detach failed"); + return HTTP_INTERNAL_SERVER_ERROR; + } } parent_pid = ap_my_pid = getpid(); }