From ba4b980ca35d1e1de656879dfd9a6d940e345dff Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Wed, 25 Sep 2013 16:23:28 +0000 Subject: [PATCH] worker MPM: Don't forcibly kill worker threads if the child process is exiting gracefully. Submitted by: Oracle, via trawick This modification was made some years ago for Oracle HTTP Server by an Oracle employee. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1526220 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ server/mpm/worker/worker.c | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index bd7bedc48be..23c88390177 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) worker MPM: Don't forcibly kill worker threads if the child process is + exiting gracefully. [Oracle Corporation] + *) mod_proxy: Add ap_connection_reusable() for checking if a connection is reusable as of this point in processing. [Jeff Trawick] diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 47c144d4ef8..85b7adb0da3 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -1129,7 +1129,8 @@ static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy) return NULL; } -static void join_workers(apr_thread_t *listener, apr_thread_t **threads) +static void join_workers(apr_thread_t *listener, apr_thread_t **threads, + int mode) { int i; apr_status_t rv, thread_rv; @@ -1173,12 +1174,14 @@ static void join_workers(apr_thread_t *listener, apr_thread_t **threads) for (i = 0; i < threads_per_child; i++) { if (threads[i]) { /* if we ever created this thread */ + if (mode != ST_GRACEFUL) { #ifdef HAVE_PTHREAD_KILL - apr_os_thread_t *worker_os_thread; + apr_os_thread_t *worker_os_thread; - apr_os_thread_get(&worker_os_thread, threads[i]); - pthread_kill(*worker_os_thread, WORKER_SIGNAL); + apr_os_thread_get(&worker_os_thread, threads[i]); + pthread_kill(*worker_os_thread, WORKER_SIGNAL); #endif + } rv = apr_thread_join(&thread_rv, threads[i]); if (rv != APR_SUCCESS) { @@ -1324,7 +1327,7 @@ static void child_main(int child_num_arg) * If the worker hasn't exited, then this blocks until * they have (then cleans up). */ - join_workers(ts->listener, threads); + join_workers(ts->listener, threads, ST_UNGRACEFUL); } else { /* !one_process */ /* remove SIGTERM from the set of blocked signals... if one of @@ -1364,7 +1367,8 @@ static void child_main(int child_num_arg) * If the worker hasn't exited, then this blocks until * they have (then cleans up). */ - join_workers(ts->listener, threads); + join_workers(ts->listener, threads, + rv == AP_MPM_PODX_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL); } free(threads); -- 2.47.3