]> granicus.if.org Git - apache/commitdiff
Provide a function for closing all of the listeners.
authorColm MacCarthaigh <colm@apache.org>
Wed, 24 Aug 2005 16:51:20 +0000 (16:51 +0000)
committerColm MacCarthaigh <colm@apache.org>
Wed, 24 Aug 2005 16:51:20 +0000 (16:51 +0000)
  * This is useful for properly implementing a graceful stop and restart
    where we want child processess to be able to carry on serving a request
    but "de-listen" from a port. So that another instance entirely can be
    started in our place, or to unbind from a "Listen" directive an admin
    has removed from the configuration.

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

include/ap_listen.h
server/listen.c

index d98949f37923decff97fbd1fbd781a1915ea4572..ecff132a37b3ebd6553019975ab0ad752ffcb08d 100644 (file)
@@ -77,6 +77,11 @@ AP_DECLARE(void) ap_listen_pre_config(void);
  */ 
 AP_DECLARE(int) ap_setup_listeners(server_rec *s);
 
+/**
+ * Loop through the global ap_listen_rec list and close each of the sockets.
+ */
+AP_DECLARE_NONSTD(void) ap_close_listeners();
+
 /* Although these functions are exported from libmain, they are not really
  * public functions.  These functions are actually called while parsing the
  * config file, when one of the LISTEN_COMMANDS directives is read.  These
index 6a3ee9e7bf9ae12ffcfb1a676d8dbb3944003059..15ad6a0ff90ed5974588a8b974668979c55b228d 100644 (file)
@@ -238,17 +238,10 @@ static void ap_apply_accept_filter(apr_pool_t *p, ap_listen_rec *lis,
 
 static apr_status_t close_listeners_on_exec(void *v)
 {
-    ap_listen_rec *lr;
-
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        apr_socket_close(lr->sd);
-        lr->active = 0;
-    }
-
+    ap_close_listeners();
     return APR_SUCCESS;
 }
 
-
 static const char *alloc_listener(process_rec *process, char *addr, 
                                   apr_port_t port, const char* proto)
 {
@@ -541,6 +534,15 @@ AP_DECLARE(int) ap_setup_listeners(server_rec *s)
     return num_listeners;
 }
 
+AP_DECLARE_NONSTD(void) ap_close_listeners() {
+    ap_listen_rec *lr;
+
+    for (lr = ap_listeners; lr; lr = lr->next) {
+        apr_socket_close(lr->sd);
+        lr->active = 0;
+    }
+}
+
 AP_DECLARE(void) ap_listen_pre_config(void)
 {
     old_listeners = ap_listeners;