When I updated to HEAD just now on my Solaris box, httpd wouldn't start with this:
[Mon Aug 11 19:10:08 2003] [crit] (EAI 8)host/servname not known: alloc_listener: failed to set up sockaddr for :: Syntax error on line 217 of .../conf/httpd.conf: Listen setup failed
Line 217 is:
Listen 8080
Something that simple should work. Yet, it looks like if we have IPv6 compiled in, we will assume that all non-qualified addresses are IPv6. That seems wrong. (I have no idea why this never appeared before.)
Any arguments on tossing the find_default_family function altogether, and just going to 0.0.0.0 when the addr isn't specified? If you want IPv6, you should explicitly specify it with 'Listen ::8080' or something, but assuming that since we have IPv6 available that the unqualified addresses must be IPv6 doesn't make sense and is badness. -- justin
Index: server/listen.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/listen.c,v retrieving revision 1.86 diff -u -r1.86 listen.c --- server/listen.c 31 Mar 2003 04:30:38 -0000 1.86 +++ server/listen.c 12 Aug 2003 02:22:34 -0000 @@ -235,38 +235,6 @@ }
-static void find_default_family(apr_pool_t *p)
-{
-#if APR_HAVE_IPV6
- /* We know the platform supports IPv6, but this particular
- * system may not have IPv6 enabled. See if we can get an
- * AF_INET6 socket and bind to an ephemeral port. (On most
- * systems, getting an AF_INET6 socket is a sufficient test.
- * On certain levels of OpenUNIX, getting the socket is
- * successful but bind always returns ENETUNREACH.)
- */
- if (default_family == APR_UNSPEC) {
- apr_status_t sock_rv;
- apr_socket_t *tmp_sock;
- apr_sockaddr_t *sa;
-
- if ((sock_rv = apr_socket_create(&tmp_sock, APR_INET6, SOCK_STREAM, p))
- == APR_SUCCESS &&
- apr_sockaddr_info_get(&sa, NULL, APR_INET6, 0, 0, p) == APR_SUCCESS &&
- apr_bind(tmp_sock, sa) == APR_SUCCESS) {
- default_family = APR_INET6;
- }
- else {
- default_family = APR_INET;
- }
- if (sock_rv == APR_SUCCESS) {
- apr_socket_close(tmp_sock);
- }
- }
-#endif
-}
-
-
static const char *alloc_listener(process_rec *process, char *addr, apr_port_t port)
{
ap_listen_rec **walk;
@@ -276,21 +244,10 @@
apr_sockaddr_t *sa;
if (!addr) { /* don't bind to specific interface */
- find_default_family(process->pool);
- switch(default_family) {
- case APR_INET:
- addr = "0.0.0.0";
- break;
-
-#if APR_HAVE_IPV6
- case APR_INET6:
- addr = "::";
- break;
-#endif
-
- default:
- ap_assert(1 != 1); /* should not occur */
- }
+ /* We should default to IPv4 when we have no address specified
+ * even if we have IPv6.
+ */
+ addr = "0.0.0.0";
}/* see if we've got an old listener for this address:port */
