On Thu, Aug 25, 2005 at 11:29:17AM -0400, Jeff Trawick wrote:
> With this patch I can tell from syscall trace that we only get one
> socket now. But server dies mysteriously later. The mysterious death
> doesn't occur with "Listen 0.0.0.0:8080" so it is apparently related
> to this socket management.
o.k., closer, this should fix that too;
Index: listen.c
===================================================================
--- listen.c (revision 239742)
+++ listen.c (working copy)
@@ -361,6 +361,31 @@
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(&lr->next->bind_addr->sa.sin6.sin6_addr)) {
+ ap_listen_rec * spare, * pivot;
+
+ /* Standard link-list swap */
+ spare = lr->next->next;
+ pivot = lr->next;
+ lr->next->next = lr;
+ lr->next = spare;
+ lr = pivot;
+
+ /* If we are the head of the list, update the global pointer */
+ if(!previous) {
+ ap_listeners = lr;
+ }
+ }
+
if (lr->active) {
++num_open;
}
--
Colm MacCárthaigh Public Key: [EMAIL PROTECTED]