]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1882370 from trunk:
authorYann Ylavic <ylavic@apache.org>
Sun, 18 Apr 2021 17:04:34 +0000 (17:04 +0000)
committerYann Ylavic <ylavic@apache.org>
Sun, 18 Apr 2021 17:04:34 +0000 (17:04 +0000)
Adjust signal handler before unblocking

* 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.

Submitted by: rpluem
Reviewed by: ylavic, jorton, icing

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1888917 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/CHANGES b/CHANGES
index f372068318d550fbd5500663cb0527cc7370dacc..f6ffa714e50b3b6c450e44e7ca6a4acd03839a39 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.47
 
+  *) MPM event/worker: Fix possible crash in child process on early signal
+     delivery.  PR 64533.  [Ruediger Pluem]
+
   *) mod_http2: sync with github standalone version 1.15.17
      - Log requests and sent the configured error response in case of early detected
        errors like too many or too long headers. [Ruediger Pluem]
index 18403cf97e9918064ba5c007d5ee8a6ae5069aac..6ba01576b054edb07e7312b967a2fe3311255a00 100644 (file)
@@ -1583,8 +1583,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;
@@ -2570,8 +2570,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 ccaeeba9ce5d3ed93748c82e906739444ef715fb..d44190bb339e34c285b5722089ddea49d25b4137 100644 (file)
@@ -553,8 +553,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 */
@@ -748,8 +748,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) {
@@ -1230,8 +1230,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);