]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
merge from trunk:
authorJeff Trawick <trawick@apache.org>
Mon, 24 Jul 2006 01:43:24 +0000 (01:43 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 24 Jul 2006 01:43:24 +0000 (01:43 +0000)
  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

CHANGES
STATUS
server/mpm/worker/worker.c

diff --git a/CHANGES b/CHANGES
index 70eb9189b7b0d85010236e78371ffe019db461c7..5f3b41ed369ff013e05e1e70cda45c604b88726e 100644 (file)
--- 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 <chrisd pearsoncmg.com> ]
diff --git a/STATUS b/STATUS
index 57ce6aa40600854f68ea17482ad2176b698205dc..5906ab24e1462865250a9e838b2cc115a951c5b9 100644 (file)
--- 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:
index 142b7a42e1442b10ed2edaad933d5a6dfe82353a..b71cd23771d40b61a2d63cbf2786b7ceb610c504 100644 (file)
@@ -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,