]> granicus.if.org Git - apache/commitdiff
Close sockets on worker MPM when doing a graceless restart. This should
authorJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 1 May 2002 07:15:39 +0000 (07:15 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 1 May 2002 07:15:39 +0000 (07:15 +0000)
resolve some segfaults see when doing such restarts.

(Justin tweaked the palloc/memset in favor of calloc.)

Submitted by: Aaron Bannert
Reviewed by: Greg Ames, Sander Striker, Justin Erenkrantz

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94886 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/mpm/worker/worker.c

diff --git a/CHANGES b/CHANGES
index b6a954bbbf7a24d0f5439ea4ec5d01799d46fcee..9f2357a2e826c6dcd4c38b3651e3a225e6271c31 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.37
 
+  *) Close sockets on worker MPM when doing a graceless restart.
+     [Aaron Bannert]
+
   *) Reverted a minor optimization in mod_ssl.c that used the vhost ID
      as the session id context rather that a MD5 hash of that vhost ID,
      because it caused very long vhost id's to be unusable with mod_ssl.
index 40b6bc9ff9d6b52ab4829cf28740fe034cbdf0f4..65643848617080007ff2871e0d66a48efc82123e 100644 (file)
@@ -252,6 +252,21 @@ static apr_proc_mutex_t *accept_mutex;
  */
 #define LISTENER_SIGNAL     SIGHUP
 
+/* 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;
+
+static void close_worker_sockets(void)
+{
+    int i;
+    for (i = 0; i < ap_threads_per_child; i++) {
+        if (worker_sockets[i]) {
+            apr_socket_close(worker_sockets[i]);
+            worker_sockets[i] = NULL;
+        }
+    }
+}
+  
 static void wakeup_listener(void)
 {
     listener_may_exit = 1;
@@ -301,6 +316,7 @@ static void signal_threads(int mode)
         workers_may_exit = 1;
         ap_queue_interrupt_all(worker_queue);
         ap_queue_info_term(worker_queue_info);
+        close_worker_sockets(); /* forcefully kill all current connections */
     }
 }
 
@@ -912,7 +928,9 @@ worker_pop:
             }
             continue;
         }
+        worker_sockets[thread_slot] = csd;
         process_socket(ptrans, csd, process_slot, thread_slot, bucket_alloc);
+        worker_sockets[thread_slot] = NULL;
         requests_this_child--; /* FIXME: should be synchronized - aaron */
         apr_pool_clear(ptrans);
         last_ptrans = ptrans;
@@ -1002,6 +1020,9 @@ static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
         clean_child_exit(APEXIT_CHILDFATAL);
     }
 
+    worker_sockets = apr_pcalloc(pchild, ap_threads_per_child
+                                        * sizeof(apr_socket_t *));
+
     loops = prev_threads_created = 0;
     while (1) {
         /* ap_threads_per_child does not include the listener thread */