httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1629925 - in /httpd/httpd/trunk/server: ./ mpm/event/ mpm/eventopt/ mpm/mpmt_os2/ mpm/netware/ mpm/prefork/ mpm/simple/ mpm/winnt/ mpm/worker/
Date Tue, 07 Oct 2014 16:54:32 GMT
Author: ylavic
Date: Tue Oct  7 16:54:31 2014
New Revision: 1629925

URL: http://svn.apache.org/r1629925
Log:
core: ensure that MPMs return an error on runtime failure and hence that
      httpd's main process also exits with an error.


Modified:
    httpd/httpd/trunk/server/main.c
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
    httpd/httpd/trunk/server/mpm/mpmt_os2/mpmt_os2.c
    httpd/httpd/trunk/server/mpm/netware/mpm_netware.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/simple/simple_api.c
    httpd/httpd/trunk/server/mpm/simple/simple_run.c
    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
    httpd/httpd/trunk/server/mpm/worker/worker.c

Modified: httpd/httpd/trunk/server/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/main.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/main.c (original)
+++ httpd/httpd/trunk/server/main.c Tue Oct  7 16:54:31 2014
@@ -475,6 +475,7 @@ int main(int argc, const char * const ar
     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 */
 
@@ -723,7 +724,7 @@ int main(int argc, const char * const ar
 
     apr_pool_destroy(ptemp);
 
-    for (;;) {
+    do {
         ap_main_state = AP_SQ_MS_DESTROY_CONFIG;
         apr_hook_deregister_all();
         apr_pool_clear(pconf);
@@ -796,16 +797,23 @@ int main(int argc, const char * const ar
         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()
+                     "MPM run failed, exiting");
+    }
+    destroy_and_exit_process(process, rc);
 
-    return 0; /* Termination 'ok' */
+    /* NOTREACHED */
+    return !OK;
 }
 
 #ifdef AP_USING_AUTOCONF

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Tue Oct  7 16:54:31 2014
@@ -2994,7 +2994,7 @@ static int event_run(apr_pool_t * _pconf
     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

Modified: httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/eventopt.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/eventopt.c (original)
+++ httpd/httpd/trunk/server/mpm/eventopt/eventopt.c Tue Oct  7 16:54:31 2014
@@ -2815,7 +2815,7 @@ static int event_run(apr_pool_t * _pconf
     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

Modified: httpd/httpd/trunk/server/mpm/mpmt_os2/mpmt_os2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/mpmt_os2/mpmt_os2.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/mpmt_os2/mpmt_os2.c (original)
+++ httpd/httpd/trunk/server/mpm/mpmt_os2/mpmt_os2.c Tue Oct  7 16:54:31 2014
@@ -153,7 +153,7 @@ static int mpmt_os2_run(apr_pool_t *_pco
         ap_mpm_child_main(pconf);
 
         /* Outta here */
-        return 1;
+        return DONE;
     }
     else {
         /* Parent process */
@@ -163,7 +163,7 @@ static int mpmt_os2_run(apr_pool_t *_pco
         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);
@@ -176,11 +176,11 @@ static int mpmt_os2_run(apr_pool_t *_pco
             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;
+            return DONE;
         }
     }  /* Parent process */
 
-    return 0; /* Restart */
+    return OK; /* Restart */
 }
 
 

Modified: httpd/httpd/trunk/server/mpm/netware/mpm_netware.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/netware/mpm_netware.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/netware/mpm_netware.c (original)
+++ httpd/httpd/trunk/server/mpm/netware/mpm_netware.c Tue Oct  7 16:54:31 2014
@@ -872,7 +872,7 @@ static int netware_run(apr_pool_t *_pcon
     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 *_pcon
 
     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 *_pcon
         }
 
         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 *_pcon
     }
 
     mpm_main_cleanup();
-    return 0;
+    return OK;
 }
 
 static int netware_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Tue Oct  7 16:54:31 2014
@@ -978,14 +978,14 @@ static int prefork_run(apr_pool_t *_pcon
                                   s, _pconf, 0);
         if (rv != APR_SUCCESS) {
             mpm_state = AP_MPMQ_STOPPING;
-            return DONE;
+            return !OK;
         }
      }
 
     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
@@ -1001,7 +1001,7 @@ static int prefork_run(apr_pool_t *_pcon
         make_child(ap_server_conf, 0, 0);
         /* NOTREACHED */
         ap_assert(0);
-        return DONE;
+        return !OK;
     }
 
     /* Don't thrash... */
@@ -1071,7 +1071,7 @@ static int prefork_run(apr_pool_t *_pcon
                     || 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)

Modified: httpd/httpd/trunk/server/mpm/simple/simple_api.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_api.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_api.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_api.c Tue Oct  7 16:54:31 2014
@@ -35,7 +35,7 @@ static int simple_run(apr_pool_t * pconf
 
     if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
         sc->mpm_state = AP_MPMQ_STOPPING;
-        return DONE;
+        return !OK;
     }
 
     return simple_main_loop(sc);

Modified: httpd/httpd/trunk/server/mpm/simple/simple_run.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_run.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_run.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_run.c Tue Oct  7 16:54:31 2014
@@ -179,7 +179,7 @@ static int simple_run_loop(simple_core_t
             if (!APR_STATUS_IS_EINTR(rv) && !APR_STATUS_IS_TIMEUP(rv)) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                              "simple_main_loop: apr_pollcb_poll failed");
-                return DONE;
+                return !OK;
             }
         }
 
@@ -321,7 +321,7 @@ int simple_main_loop(simple_core_t * sc)
 
     rv = simple_setup_pollcb(sc);
     if (rv) {
-        return rv;
+        return !OK;
     }
 
     rv = simple_setup_workers(sc);

Modified: httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c Tue Oct  7 16:54:31 2014
@@ -1696,7 +1696,7 @@ static int winnt_run(apr_pool_t *_pconf,
     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;
         }
     }
 

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=1629925&r1=1629924&r2=1629925&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Tue Oct  7 16:54:31 2014
@@ -1817,14 +1817,14 @@ static int worker_run(apr_pool_t *_pconf
                                   s, _pconf, 0);
         if (rv != APR_SUCCESS) {
             mpm_state = AP_MPMQ_STOPPING;
-            return DONE;
+            return !OK;
         }
     }
 
     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



Mime
View raw message