]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mpm_event: make sure wakeup_listener() does its minimal job.
authorYann Ylavic <ylavic@apache.org>
Tue, 2 Jan 2018 15:29:58 +0000 (15:29 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 2 Jan 2018 15:29:58 +0000 (15:29 +0000)
Even if the listener thread is not created yet (i.e. about to be), we must
still tell it to leave, and terminate the worker queue in any case.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1819848 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/event/event.c

index a71c3dc35f5757499d0a8bf2a098b4bbc275eff7..2d71f923192e53e827e95e608fca44c9928e2bf7 100644 (file)
@@ -570,6 +570,17 @@ static void close_worker_sockets(void)
 static void wakeup_listener(void)
 {
     listener_may_exit = 1;
+
+    /* Unblock the listener if it's poll()ing */
+    if (event_pollset && listener_is_wakeable) {
+        apr_pollset_wakeup(event_pollset);
+    }
+
+    /* unblock the listener if it's waiting for a worker */
+    if (worker_queue_info) {
+        ap_queue_info_term(worker_queue_info);
+    }
+
     if (!listener_os_thread) {
         /* XXX there is an obscure path that this doesn't handle perfectly:
          *     right after listener thread is created but before
@@ -578,15 +589,6 @@ static void wakeup_listener(void)
          */
         return;
     }
-
-    /* Unblock the listener if it's poll()ing */
-    if (listener_is_wakeable) {
-        apr_pollset_wakeup(event_pollset);
-    }
-
-    /* unblock the listener if it's waiting for a worker */
-    ap_queue_info_term(worker_queue_info);
-
     /*
      * we should just be able to "kill(ap_my_pid, LISTENER_SIGNAL)" on all
      * platforms and wake up the listener thread since it is the only thread
@@ -607,7 +609,7 @@ static int terminate_mode = ST_INIT;
 
 static void signal_threads(int mode)
 {
-    if (terminate_mode == mode) {
+    if (terminate_mode >= mode) {
         return;
     }
     terminate_mode = mode;
@@ -3608,6 +3610,10 @@ static int event_pre_config(apr_pool_t * pconf, apr_pool_t * plog,
     had_healthy_child = 0;
     ap_extended_status = 0;
 
+    event_pollset = NULL;
+    worker_queue_info = NULL;
+    listener_os_thread = NULL;
+
     return OK;
 }