From: Stefan Eissing Date: Thu, 17 Mar 2016 09:42:18 +0000 (+0000) Subject: Merge r1629925, r1629927, r1629928, r1733162, r1733173 from trunk: X-Git-Tag: 2.4.19~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04032463debb70ae63d4233d3b1bbe5b7548fd30;p=apache Merge r1629925, r1629927, r1629928, r1733162, r1733173 from trunk: Ensure that httpd exits with an error status when the MPM fails to run. [Yann Ylavic] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1735381 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index caf8a8df27..12ed720e6f 100644 --- a/CHANGES +++ b/CHANGES @@ -105,6 +105,9 @@ Changes with Apache 2.4.19 the SSLVerifyDepth applied with the default/handshaken vhost differs from the one applicable with the finally selected vhost. [Yann Ylavic] + *) core: Ensure that httpd exits with an error status when the MPM fails + to run. [Yann Ylavic] + *) mod_ssl: Add SSLOCSPProxyURL to add the possibility to do all queries to OCSP responders through a HTTP proxy. [Ruediger Pluem] diff --git a/STATUS b/STATUS index 208248d4b7..6964818e29 100644 --- a/STATUS +++ b/STATUS @@ -112,16 +112,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) core: Ensure that httpd exits with an error status when the MPM fails - to run. - trunk patch: http://svn.apache.org/r1629925 - http://svn.apache.org/r1629927 - http://svn.apache.org/r1629928 - http://svn.apache.org/r1733162 - http://svn.apache.org/r1733173 - 2.4.x patch: http://home.apache.org/~ylavic/patches/httpd-2.4.x-exit_with_error_on_mpm_failure.patch - +1: ylavic, jim, icing - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/server/main.c b/server/main.c index 28d1872055..cfa5a9d3e5 100644 --- a/server/main.c +++ b/server/main.c @@ -453,6 +453,7 @@ int main(int argc, const char * const argv[]) module **mod; const char *opt_arg; APR_OPTIONAL_FN_TYPE(ap_signal_server) *signal_server; + int rc = OK; AP_MONCONTROL(0); /* turn off profiling of startup */ @@ -701,7 +702,7 @@ int main(int argc, const char * const argv[]) apr_pool_destroy(ptemp); - for (;;) { + do { ap_main_state = AP_SQ_MS_DESTROY_CONFIG; apr_hook_deregister_all(); apr_pool_clear(pconf); @@ -774,16 +775,23 @@ int main(int argc, const char * const argv[]) ap_run_optional_fn_retrieve(); ap_main_state = AP_SQ_MS_RUN_MPM; - if (ap_run_mpm(pconf, plog, ap_server_conf) != OK) - break; + rc = ap_run_mpm(pconf, plog, ap_server_conf); apr_pool_lock(pconf, 0); - } - apr_pool_lock(pconf, 0); - destroy_and_exit_process(process, 0); + } while (rc == OK); + + if (rc == DONE) { + rc = OK; + } + else if (rc != OK) { + ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL, APLOGNO(02818) + "MPM run failed, exiting"); + } + destroy_and_exit_process(process, rc); - return 0; /* Termination 'ok' */ + /* NOTREACHED */ + return !OK; } #ifdef AP_USING_AUTOCONF diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 23368c7618..631914eba3 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -2812,7 +2812,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) if (!retained->is_graceful) { if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { mpm_state = AP_MPMQ_STOPPING; - return DONE; + return !OK; } /* fix the generation number in the global score; we just got a new, * cleared scoreboard @@ -3074,7 +3074,7 @@ static int event_open_logs(apr_pool_t * p, apr_pool_t * plog, ap_log_error(APLOG_MARK, APLOG_ALERT | level_flags, 0, (startup ? NULL : s), "no listening sockets available, shutting down"); - return DONE; + return !OK; } if (one_process) { @@ -3089,7 +3089,7 @@ static int event_open_logs(apr_pool_t * p, apr_pool_t * plog, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not duplicate listeners"); - return DONE; + return !OK; } all_buckets = apr_pcalloc(pconf, num_buckets * sizeof(*all_buckets)); @@ -3099,7 +3099,7 @@ static int event_open_logs(apr_pool_t * p, apr_pool_t * plog, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not open pipe-of-death"); - return DONE; + return !OK; } all_buckets[i].listeners = listen_buckets[i]; } diff --git a/server/mpm/mpmt_os2/mpmt_os2.c b/server/mpm/mpmt_os2/mpmt_os2.c index 2380e2e537..ccce767fab 100644 --- a/server/mpm/mpmt_os2/mpmt_os2.c +++ b/server/mpm/mpmt_os2/mpmt_os2.c @@ -102,7 +102,7 @@ typedef struct { listen_socket_t listeners[1]; } parent_info_t; -static char master_main(); +static int master_main(); static void spawn_child(int slot); void ap_mpm_child_main(apr_pool_t *pconf); static void set_signals(); @@ -153,34 +153,35 @@ static int mpmt_os2_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) ap_mpm_child_main(pconf); /* Outta here */ - return 1; + return DONE; } else { /* Parent process */ - char restart; + int rc; is_parent_process = TRUE; if (ap_setup_listeners(ap_server_conf) < 1) { ap_log_error(APLOG_MARK, APLOG_ALERT, 0, s, APLOGNO(00200) "no listening sockets available, shutting down"); - return 1; + return !OK; } ap_log_pid(pconf, ap_pid_fname); - restart = master_main(); + rc = master_main(); ++ap_my_generation; ap_scoreboard_image->global->running_generation = ap_my_generation; - if (!restart) { + if (rc != OK) { ap_remove_pid(pconf, ap_pid_fname); ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, APLOGNO(00201) - "caught SIGTERM, shutting down"); - return 1; + "caught %s, shutting down", + (rc == DONE) ? "SIGTERM" : "error"); + return rc; } } /* Parent process */ - return 0; /* Restart */ + return OK; /* Restart */ } @@ -188,7 +189,7 @@ static int mpmt_os2_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) /* Main processing of the parent process * returns TRUE if restarting */ -static char master_main() +static int master_main() { server_rec *s = ap_server_conf; ap_listen_rec *lr; @@ -203,7 +204,7 @@ static char master_main() if (ap_setup_listeners(ap_server_conf) < 1) { ap_log_error(APLOG_MARK, APLOG_ALERT, 0, s, APLOGNO(00202) "no listening sockets available, shutting down"); - return FALSE; + return !OK; } /* Allocate a shared memory block for the array of listeners */ @@ -219,7 +220,7 @@ static char master_main() if (rc) { ap_log_error(APLOG_MARK, APLOG_ALERT, APR_FROM_OS_ERROR(rc), s, APLOGNO(00203) "failure allocating shared memory, shutting down"); - return FALSE; + return !OK; } /* Store the listener sockets in the shared memory area for our children to see */ @@ -236,7 +237,7 @@ static char master_main() if (rc) { ap_log_error(APLOG_MARK, APLOG_ALERT, APR_FROM_OS_ERROR(rc), s, APLOGNO(00204) "failure creating accept mutex, shutting down"); - return FALSE; + return !OK; } parent_info->accept_mutex = ap_mpm_accept_mutex; @@ -251,7 +252,7 @@ static char master_main() if (rc) { ap_log_error(APLOG_MARK, APLOG_ERR, APR_FROM_OS_ERROR(rc), ap_server_conf, APLOGNO(00205) "unable to allocate shared memory for scoreboard , exiting"); - return FALSE; + return !OK; } ap_init_scoreboard(sb_mem); @@ -266,7 +267,7 @@ static char master_main() if (one_process) { ap_scoreboard_image->parent[0].pid = getpid(); ap_mpm_child_main(pconf); - return FALSE; + return DONE; } while (!restart_pending && !shutdown_pending) { @@ -318,7 +319,7 @@ static char master_main() } DosFreeMem(parent_info); - return restart_pending; + return restart_pending ? OK : DONE; } diff --git a/server/mpm/netware/mpm_netware.c b/server/mpm/netware/mpm_netware.c index d86ed23f6a..42d2a54196 100644 --- a/server/mpm/netware/mpm_netware.c +++ b/server/mpm/netware/mpm_netware.c @@ -872,7 +872,7 @@ static int netware_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (setup_listeners(s)) { ap_log_error(APLOG_MARK, APLOG_ALERT, status, s, APLOGNO(00223) "no listening sockets available, shutting down"); - return -1; + return !OK; } restart_pending = shutdown_pending = 0; @@ -880,7 +880,7 @@ static int netware_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (!is_graceful) { if (ap_run_pre_mpm(s->process->pool, SB_NOT_SHARED) != OK) { - return 1; + return !OK; } } @@ -949,7 +949,7 @@ static int netware_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) } mpm_main_cleanup(); - return 1; + return DONE; } else { /* the only other way out is a restart */ /* advance to the next generation */ @@ -972,7 +972,7 @@ static int netware_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) } mpm_main_cleanup(); - return 0; + return OK; } static int netware_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index f2b4e410cc..68709dbb5d 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -963,7 +963,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (!retained->is_graceful) { if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { mpm_state = AP_MPMQ_STOPPING; - return DONE; + return !OK; } /* fix the generation number in the global score; we just got a new, * cleared scoreboard @@ -979,7 +979,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) make_child(ap_server_conf, 0, 0); /* NOTREACHED */ ap_assert(0); - return DONE; + return !OK; } /* Don't thrash since num_buckets depends on the @@ -1059,7 +1059,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) || ap_get_scoreboard_process(child_slot)->generation == retained->my_generation) { mpm_state = AP_MPMQ_STOPPING; - return DONE; + return !OK; } else { ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(00166) @@ -1296,7 +1296,7 @@ static int prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_ALERT | level_flags, 0, (startup ? NULL : s), "no listening sockets available, shutting down"); - return DONE; + return !OK; } if (one_process) { @@ -1311,7 +1311,7 @@ static int prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not duplicate listeners"); - return DONE; + return !OK; } all_buckets = apr_pcalloc(pconf, num_buckets * sizeof(prefork_child_bucket)); @@ -1320,7 +1320,7 @@ static int prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not open pipe-of-death"); - return DONE; + return !OK; } /* Initialize cross-process accept lock (safe accept needed only) */ if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", i), @@ -1330,7 +1330,7 @@ static int prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not create accept mutex"); - return DONE; + return !OK; } all_buckets[i].listeners = listen_buckets[i]; } diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 3d9ef15e5e..cf11e0cc21 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1660,7 +1660,7 @@ static int winnt_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, s if (ap_setup_listeners(s) < 1) { ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_STARTUP, 0, NULL, APLOGNO(00451) "no listening sockets available, shutting down"); - return DONE; + return !OK; } return OK; @@ -1713,7 +1713,7 @@ static int winnt_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) if (!restart && ((parent_pid == my_pid) || one_process)) { /* Set up the scoreboard. */ if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { - return DONE; + return !OK; } } diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 89f7ae11e4..be3895064b 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -1813,7 +1813,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (!retained->is_graceful) { if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { mpm_state = AP_MPMQ_STOPPING; - return DONE; + return !OK; } /* fix the generation number in the global score; we just got a new, * cleared scoreboard @@ -2031,7 +2031,7 @@ static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_ALERT | level_flags, 0, (startup ? NULL : s), "no listening sockets available, shutting down"); - return DONE; + return !OK; } if (one_process) { @@ -2046,7 +2046,7 @@ static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not duplicate listeners"); - return DONE; + return !OK; } all_buckets = apr_pcalloc(pconf, num_buckets * sizeof(*all_buckets)); @@ -2056,7 +2056,7 @@ static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not open pipe-of-death"); - return DONE; + return !OK; } /* Initialize cross-process accept lock (safe accept needed only) */ if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", i), @@ -2066,7 +2066,7 @@ static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ? NULL : s), "could not create accept mutex"); - return DONE; + return !OK; } all_buckets[i].listeners = listen_buckets[i]; }