From: Jeff Trawick Date: Mon, 24 Jul 2006 01:43:24 +0000 (+0000) Subject: merge from trunk: X-Git-Tag: 2.2.3~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8f37285d1c8837e30d712a542ef6e79ab34ba0d;p=thirdparty%2Fapache%2Fhttpd.git merge from trunk: Worker MPM: On graceless shutdown or restart, send signals to each worker thread to wake them up if they're polling on a Keep-Alive connection. PR 38737. [Chris Darroch] PR: 38737 Reviewed by: chrisd, trawick, niq git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@424876 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 70eb9189b7b..5f3b41ed369 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.3 + *) Worker MPM: On graceless shutdown or restart, send signals to + each worker thread to wake them up if they're polling on a + Keep-Alive connection. PR 38737. [Chris Darroch] + *) worker and event MPMs: fix excessive forking if fork() or child_init take a long time. PR 39275. [Greg Ames, Jeff Trawick, Chris Darroch ] diff --git a/STATUS b/STATUS index 57ce6aa4060..5906ab24e14 100644 --- a/STATUS +++ b/STATUS @@ -76,15 +76,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * Worker MPM: On graceless shutdown or restart, send signals to - each worker thread to wake them up if they're polling on a - Keep-Alive connection. PR 38737. - Trunk version of patch: - http://svn.apache.org/viewvc?view=rev&revision=409715 - 2.2.x version of patch: - http://issues.apache.org/bugzilla/attachment.cgi?id=18355 - +1: chrisd, trawick, niq - * mod_cache: Make caching of reverse SSL proxies possible again. PR 39593. Trunk version of patch: diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 142b7a42e14..b71cd23771d 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -213,6 +213,19 @@ static apr_proc_mutex_t *accept_mutex; */ #define LISTENER_SIGNAL SIGHUP +/* The WORKER_SIGNAL signal will be sent from the main thread to the + * worker threads during an ungraceful restart or shutdown. + * This ensures that on systems (i.e., Linux) where closing the worker + * socket doesn't awake the worker thread when it is polling on the socket + * (especially in apr_wait_for_io_or_timeout() when handling + * Keep-Alive connections), close_worker_sockets() and join_workers() + * still function in timely manner and allow ungraceful shutdowns to + * proceed to completion. Otherwise join_workers() doesn't return + * before the main process decides the child process is non-responsive + * and sends a SIGKILL. + */ +#define WORKER_SIGNAL AP_SIG_GRACEFUL + /* An array of socket descriptors in use by each thread used to * perform a non-graceful (forced) shutdown of the server. */ static apr_socket_t **worker_sockets; @@ -821,6 +834,11 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy) ap_scoreboard_image->servers[process_slot][thread_slot].generation = ap_my_generation; ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL); +#ifdef HAVE_PTHREAD_KILL + unblock_signal(WORKER_SIGNAL); + apr_signal(WORKER_SIGNAL, dummy_signal_handler); +#endif + while (!workers_may_exit) { if (!is_idle) { rv = ap_queue_info_set_idle(worker_queue_info, last_ptrans); @@ -1076,6 +1094,13 @@ static void join_workers(apr_thread_t *listener, apr_thread_t **threads) for (i = 0; i < ap_threads_per_child; i++) { if (threads[i]) { /* if we ever created this thread */ +#ifdef HAVE_PTHREAD_KILL + apr_os_thread_t *worker_os_thread; + + 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) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,