Commit d4ba8b52 authored by Stefan Eissing's avatar Stefan Eissing
Browse files

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
parent da121494
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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]

+0 −10
Original line number Diff line number Diff line
@@ -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 ]
+15 −7
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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];
    }
+17 −16
Original line number Diff line number Diff line
@@ -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;
}


Loading