httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r806010 - in /httpd/httpd/trunk: include/ap_listen.h server/listen.c
Date Wed, 19 Aug 2009 23:55:14 GMT
Author: niq
Date: Wed Aug 19 23:55:14 2009
New Revision: 806010

URL: http://svn.apache.org/viewvc?rev=806010&view=rev
Log:
Don't require all listeners to be created equal ...

Modified:
    httpd/httpd/trunk/include/ap_listen.h
    httpd/httpd/trunk/server/listen.c

Modified: httpd/httpd/trunk/include/ap_listen.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_listen.h?rev=806010&r1=806009&r2=806010&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_listen.h (original)
+++ httpd/httpd/trunk/include/ap_listen.h Wed Aug 19 23:55:14 2009
@@ -34,6 +34,7 @@
 extern "C" {
 #endif
 
+typedef struct ap_slave_t ap_slave_t;
 typedef struct ap_listen_rec ap_listen_rec;
 typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
 
@@ -68,6 +69,8 @@
      * The default protocol for this listening socket.
      */
     const char* protocol;
+
+    ap_slave_t *slave;
 };
 
 /**
@@ -92,6 +95,7 @@
  * Loop through the global ap_listen_rec list and close each of the sockets.
  */
 AP_DECLARE_NONSTD(void) ap_close_listeners(void);
+AP_DECLARE_NONSTD(int) ap_close_listeners_selected(ap_slave_t*);
 
 /* Although these functions are exported from libmain, they are not really
  * public functions.  These functions are actually called while parsing the

Modified: httpd/httpd/trunk/server/listen.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/listen.c?rev=806010&r1=806009&r2=806010&view=diff
==============================================================================
--- httpd/httpd/trunk/server/listen.c (original)
+++ httpd/httpd/trunk/server/listen.c Wed Aug 19 23:55:14 2009
@@ -234,7 +234,8 @@
 }
 
 static const char *alloc_listener(process_rec *process, char *addr,
-                                  apr_port_t port, const char* proto)
+                                  apr_port_t port, const char* proto,
+                                  void *dummy)
 {
     ap_listen_rec **walk, *last;
     apr_status_t status;
@@ -269,6 +270,9 @@
     }
 
     if (found_listener) {
+        if (ap_listeners->slave != dummy) {
+            return "Cannot define a slave on the same IP:port as a Listener";
+        }
         return NULL;
     }
 
@@ -326,6 +330,7 @@
             last->next = new;
             last = new;
         }
+        new->slave = dummy;
     }
 
     return NULL;
@@ -581,6 +586,22 @@
         lr->active = 0;
     }
 }
+AP_DECLARE_NONSTD(int) ap_close_selected_listeners(ap_slave_t *slave)
+{
+    ap_listen_rec *lr;
+    int n = 0;
+
+    for (lr = ap_listeners; lr; lr = lr->next) {
+        if (lr->slave != slave) {
+            apr_socket_close(lr->sd);
+            lr->active = 0;
+        }
+        else {
+            ++n;
+        }
+    }
+    return n;
+}
 
 AP_DECLARE(void) ap_listen_pre_config(void)
 {
@@ -589,7 +610,10 @@
     ap_listenbacklog = DEFAULT_LISTENBACKLOG;
 }
 
-
+/* Hack: populate an extra field
+ * When this gets called from a Listen directive, dummy is null.
+ * So we can use non-null dummy to pass a data pointer without conflict
+ */
 AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
                                                 int argc, char *const argv[])
 {
@@ -636,7 +660,7 @@
         ap_str_tolower(proto);
     }
 
-    return alloc_listener(cmd->server->process, host, port, proto);
+    return alloc_listener(cmd->server->process, host, port, proto, dummy);
 }
 
 AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd,



Mime
View raw message