]> granicus.if.org Git - apache/commitdiff
Change Listen directive to bind to all addresses returned by
authorJustin Erenkrantz <jerenkrantz@apache.org>
Fri, 15 Aug 2003 02:25:41 +0000 (02:25 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Fri, 15 Aug 2003 02:25:41 +0000 (02:25 +0000)
apr_sockaddr_info_get when a hostname is not specified.

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

CHANGES
server/listen.c

diff --git a/CHANGES b/CHANGES
index 152c5c23d16200da1c0f58b9a77285e410b291f4..111fa74c37f5c5439447bf538b1da62bc41c90db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,9 +2,12 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Change Listen directive to bind to all addresses when a hostname is
+     not specified.  [Justin Erenkrantz]
+
   *) Correct failure with Listen directives on machines with IPv6 enabled.
      [Colm MacCárthaigh <colm@stdlib.net>, Justin Erenkrantz]
-  
+
   *) Fix a link failure in mod_ssl when the OpenSSL libraries contain
      the ENGINE functions but the engine header files are missing.
      [Cliff Woolley]
index c91da9f8dbfa8940c9f1b3722301d8e39aa7be70..10aca871fff6bfc8f09b0d0c06f697fd209097f9 100644 (file)
@@ -232,16 +232,18 @@ static apr_status_t close_listeners_on_exec(void *v)
 static const char *alloc_listener(process_rec *process, char *addr, apr_port_t port)
 {
     ap_listen_rec **walk;
-    ap_listen_rec *new;
     apr_status_t status;
-    apr_port_t oldport;
     apr_sockaddr_t *sa;
+    int found_listener = 0;
 
     /* see if we've got an old listener for this address:port */
-    for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
+    for (walk = &old_listeners; *walk;) {
         sa = (*walk)->bind_addr;
         /* Some listeners are not real so they will not have a bind_addr. */
         if (sa) {
+            ap_listen_rec *new;
+            apr_port_t oldport;
+
             apr_sockaddr_port_get(&oldport, sa);
             /* If both ports are equivalent, then if their names are equivalent,
              * then we will re-use the existing record.
@@ -253,16 +255,20 @@ static const char *alloc_listener(process_rec *process, char *addr, apr_port_t p
                 *walk = new->next;
                 new->next = ap_listeners;
                 ap_listeners = new;
-                return NULL;
+                found_listener = 1;
+                continue;
             }
         }
+
+        walk = &(*walk)->next;
+    }
+
+    if (found_listener) {
+        return NULL;
     }
 
-    /* this has to survive restarts */
-    new = apr_palloc(process->pool, sizeof(ap_listen_rec));
-    new->active = 0;
-    if ((status = apr_sockaddr_info_get(&new->bind_addr, addr, APR_UNSPEC,
-                                        port, 0, process->pool))
+    if ((status = apr_sockaddr_info_get(&sa, addr, APR_UNSPEC, port, 0,
+                                        process->pool))
         != APR_SUCCESS) {
         ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
                       "alloc_listener: failed to set up sockaddr for %s",
@@ -270,33 +276,40 @@ static const char *alloc_listener(process_rec *process, char *addr, apr_port_t p
         return "Listen setup failed";
     }
 
-    while (new->bind_addr) {
+    while (sa) {
+        ap_listen_rec *new;
+
+        /* this has to survive restarts */
+        new = apr_palloc(process->pool, sizeof(ap_listen_rec));
+        new->active = 0;
+        new->bind_addr = sa;
+
+        /* Go to the next sockaddr. */
+        sa = sa->next;
+
         status = apr_socket_create(&new->sd, new->bind_addr->family,
                                     SOCK_STREAM, process->pool);
+
 #if APR_HAVE_IPV6
         /* What could happen is that we got an IPv6 address, but this system
          * doesn't actually support IPv6.  Try the next address.
          */
         if (status != APR_SUCCESS && !addr &&
             new->bind_addr->family == APR_INET6) {
-            new->bind_addr = new->bind_addr->next;
+            continue;
         }
-        else {
-            break;
-        }
-#else
-        break;
 #endif
-    }
+        if (status != APR_SUCCESS) {
+            ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
+                          "alloc_listener: failed to get a socket for %s",
+                          addr);
+            return "Listen setup failed";
+        }
 
-    if (status != APR_SUCCESS) {
-        ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
-                      "alloc_listener: failed to get a socket for %s", addr);
-        return "Listen setup failed";
+        new->next = ap_listeners;
+        ap_listeners = new;
     }
 
-    new->next = ap_listeners;
-    ap_listeners = new;
     return NULL;
 }