]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Adjust signal handler before unblocking
authorRuediger Pluem <rpluem@apache.org>
Fri, 9 Oct 2020 19:32:27 +0000 (19:32 +0000)
committerRuediger Pluem <rpluem@apache.org>
Fri, 9 Oct 2020 19:32:27 +0000 (19:32 +0000)
* server/mpm/event/event.c: Set the new signal handler before unblocking the
  signal as otherwise queued signals get delivered to the old handler
  immediately when the signal is unblocked.

* server/mpm/worker/worker.c: Same thing as with event.

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

server/mpm/event/event.c
server/mpm/worker/worker.c

index 69384652b804b4f8eb95be3c5c5819ed2d555e28..d949a0ad742775d06e254f72de80fa592e6f5cb5 100644 (file)
@@ -1836,8 +1836,8 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
     /* Unblock the signal used to wake this thread up, and set a handler for
      * it.
      */
-    unblock_signal(LISTENER_SIGNAL);
     apr_signal(LISTENER_SIGNAL, dummy_signal_handler);
+    unblock_signal(LISTENER_SIGNAL);
 
     for (;;) {
         timer_event_t *te;
@@ -2897,8 +2897,8 @@ static void child_main(int child_num_arg, int child_bucket)
          * the other threads in the process needs to take us down
          * (e.g., for MaxConnectionsPerChild) it will send us SIGTERM
          */
-        unblock_signal(SIGTERM);
         apr_signal(SIGTERM, dummy_signal_handler);
+        unblock_signal(SIGTERM);
         /* Watch for any messages from the parent over the POD */
         while (1) {
             rv = ap_mpm_podx_check(my_bucket->pod);
index 0b10eeec87b686e01c6a7f371bd18624690c4aef..94c47ef755983363997cecbc1e17a9907317a406 100644 (file)
@@ -554,8 +554,8 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy)
     /* Unblock the signal used to wake this thread up, and set a handler for
      * it.
      */
-    unblock_signal(LISTENER_SIGNAL);
     apr_signal(LISTENER_SIGNAL, dummy_signal_handler);
+    unblock_signal(LISTENER_SIGNAL);
 
     /* TODO: Switch to a system where threads reuse the results from earlier
        poll calls - manoj */
@@ -753,8 +753,8 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
                                         SERVER_STARTING, NULL);
 
 #ifdef HAVE_PTHREAD_KILL
-    unblock_signal(WORKER_SIGNAL);
     apr_signal(WORKER_SIGNAL, dummy_signal_handler);
+    unblock_signal(WORKER_SIGNAL);
 #endif
 
     while (!workers_may_exit) {
@@ -1235,8 +1235,8 @@ static void child_main(int child_num_arg, int child_bucket)
          * the other threads in the process needs to take us down
          * (e.g., for MaxConnectionsPerChild) it will send us SIGTERM
          */
-        unblock_signal(SIGTERM);
         apr_signal(SIGTERM, dummy_signal_handler);
+        unblock_signal(SIGTERM);
         /* Watch for any messages from the parent over the POD */
         while (1) {
             rv = ap_mpm_podx_check(my_bucket->pod);