On Thu, Aug 25, 2005 at 03:17:37PM +0100, Colm MacCarthaigh wrote:
> On Thu, Aug 25, 2005 at 10:11:01AM -0400, Jeff Trawick wrote:
> > first entry:
> > AF_INET; 0.0.0.0:8080
> > second (last) entry:
> > AF_INET6; [::]:8080
> 
> Yuck, We'll have to re-order the list so, or change the listen.c logic.

O.k., does this fix it;

Index: listen.c
===================================================================
--- listen.c    (revision 239742)
+++ listen.c    (working copy)
@@ -361,6 +361,27 @@
     num_open = 0;
     previous = NULL;
     for (lr = ap_listeners; lr; previous = lr, lr = lr->next) {
+        /* If we have the unspecified IPv4 address (0.0.0.0) and the
+         * unspecified IPv6 address is next, we need to swap the order
+         * of these in the list. We always try to bind to IPv6 first,
+         * then IPv4. Since an IPv6 socket might be able to receive
+         * IPv4 packets, but never the other way around.
+         */
+        if(lr->next && lr->bind_addr->family == APR_INET &&
+           lr->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY &&
+           lr->next->bind_addr->family == APR_INET6 &&
+           IN6_IS_ADDR_UNSPECIFIED(&next->bind_addr->sa.sin6.sin6_addr)) {
+            ap_listen_rec * spare;
+
+            /* Standard double-link-list swap */
+            spare = lr->next->next;
+            lr->next->previous = lr->previous;
+            lr->next->next = lr;
+            lr->previous = lr->next;
+            lr->next = spare;
+            lr = lr->previous;
+        }
+
         if (lr->active) {
             ++num_open;
         }

-- 
Colm MacCárthaigh                        Public Key: [EMAIL PROTECTED]

Reply via email to