From 39c55b426afe4aa9ebf70647822cc4a07dd8277a Mon Sep 17 00:00:00 2001 From: Ruediger Pluem Date: Fri, 9 Oct 2020 19:32:27 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1882370 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/event/event.c | 4 ++-- server/mpm/worker/worker.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 69384652b80..d949a0ad742 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -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); diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 0b10eeec87b..94c47ef7559 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -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); -- 2.47.3