Herbert Xu <[EMAIL PROTECTED]> wrote: > The patch is at the end of the message.
That patch leaked a file descriptor in the IPV6 case. So here's a new one. -- Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- diff -urN exim-3.32.old/debian/changelog exim-3.32/debian/changelog --- exim-3.32.old/debian/changelog Tue Aug 14 21:34:17 2001 +++ exim-3.32/debian/changelog Tue Aug 14 21:46:40 2001 @@ -1,3 +1,11 @@ +exim (3.32-1.1) unstable; urgency=low + + * Non-maintainer upload. + * Ignore socket(2) EAFNOSUPPORT errors. + * Ignore bind(2) EADDRINUSE errors on Linux (closes: #108285). + + -- Herbert Xu <[EMAIL PROTECTED]> Tue, 14 Aug 2001 21:46:27 +1000 + exim (3.32-1) unstable; urgency=low * New upstream version (bug fixes) diff -urN exim-3.32.old/src/daemon.c exim-3.32/src/daemon.c --- exim-3.32.old/src/daemon.c Thu Jul 26 20:07:31 2001 +++ exim-3.32/src/daemon.c Tue Aug 14 22:34:21 2001 @@ -698,17 +698,22 @@ else { + #if HAVE_IPV6 addresses = store_get(sizeof(ip_address_item)); addresses->next = NULL; - addresses->address[0] = 0; + addresses->address[0] = ':'; + addresses->address[1] = 0; listen_socket_count = 1; - #if HAVE_IPV6 addresses->next = store_get(sizeof(ip_address_item)); addresses->next->next = NULL; - addresses->next->address[0] = ':'; - addresses->next->address[1] = 0; + addresses->next->address[0] = 0; listen_socket_count++; + #else + addresses = store_get(sizeof(ip_address_item)); + addresses->next = NULL; + addresses->address[0] = 0; + listen_socket_count = 1; #endif /* HAVE_IPV6 */ } @@ -731,15 +736,21 @@ concerns. Therefore, we use IPv4 sockets for IPv4 addresses even in an IPv6 world. */ - for (ipa = addresses, sk = 0; sk < listen_socket_count; ipa = ipa->next, sk++) + for (ipa = addresses, sk = 0; ipa; ipa = ipa->next) { int i; - int af = (strchr(ipa->address, ':') != NULL)? AF_INET6 : AF_INET; + int af; + + af = (strchr(ipa->address, ':') != NULL)? AF_INET6 : AF_INET; listen_sockets[sk] = socket(af, SOCK_STREAM, 0); if (listen_sockets[sk] < 0) + { + if (af == AF_INET6 && errno == EAFNOSUPPORT) + continue; log_write(0, LOG_PANIC_DIE, "IPv%c socket creation failed: %s", (af == AF_INET6)? '6' : '4', strerror(errno)); + } /* Set SO_REUSEADDR so that the daemon can be restarted while a connection is being handled. Without this, a connection will prevent reuse of the @@ -814,6 +825,13 @@ char *addr = (ipa->address[0] == 0)? "(any IPv4)" : (ipa->address[0] == ':' && ipa->address[1] == 0)? "(any IPv6)" : ipa->address; + #ifdef linux + if (ipa->address[0] == 0 && sk && errno == EADDRINUSE) + { + close(listen_sockets[sk]); + goto CONTINUE; + } + #endif if (i == 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "socket bind() to port %d for address %s failed: %s: " @@ -824,8 +842,17 @@ } else break; } + + /* Start listening on the bound sockets, establishing the maximum backlog + of connections that is allowed. */ + + listen(listen_sockets[sk], smtp_connect_backlog); + sk++; +CONTINUE: } + listen_socket_count = sk; + /* Do a sanity check on the max connects value just to save us from getting a huge amount of store. */ @@ -851,12 +878,6 @@ smtp_host_address_slots[i] = NULL; } } - - /* Start listening on the bound sockets, establishing the maximum backlog of - connections that is allowed. */ - - for (sk = 0; sk < listen_socket_count; sk++) - listen(listen_sockets[sk], smtp_connect_backlog); } /* Set up the handler for SIGHUP, which causes a restart of the daemon. */