httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: httpd-2.0/server listen.c
Date Thu, 14 Aug 2003 00:05:26 GMT
jerenkrantz    2003/08/13 17:05:26

  Modified:    server   listen.c
  Log:
  More fun with IPv6 Listen statements.
  
  - Remove the default_family declaration as it is no longer used.
  - Fix segfault if checking NULL sa->hostname.
  - Cycle through the bind_addr list if we get an error creating an IPv6 socket
    and we're IPv6 enabled and the binding address is NULL.  The odds are that
    we just can't support IPv6.  (The twist is that apr_sockaddr_info_get should
    return bind_addr's for IPv6 and IPv4.  This strikes me as slightly more
    elegant than the find_default_family hack.)
  
  This should get us working on Linux and Netware again.
  
  Revision  Changes    Path
  1.88      +27 -12    httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -u -r1.87 -r1.88
  --- listen.c	13 Aug 2003 19:17:45 -0000	1.87
  +++ listen.c	14 Aug 2003 00:05:26 -0000	1.88
  @@ -73,12 +73,6 @@
   
   ap_listen_rec *ap_listeners = NULL;
   
  -#if APR_HAVE_IPV6
  -static int default_family = APR_UNSPEC;
  -#else
  -static int default_family = APR_INET;
  -#endif
  -
   static ap_listen_rec *old_listeners;
   static int ap_listenbacklog;
   static int send_buffer_size;
  @@ -249,8 +243,12 @@
           /* Some listeners are not real so they will not have a bind_addr. */
           if (sa) {
               apr_sockaddr_port_get(&oldport, sa);
  -            if (!strcmp(sa->hostname, addr) && port == oldport) {
  -                /* re-use existing record */
  +            /* If both ports are equivalent, then if their names are equivalent,
  +             * then we will re-use the existing record.
  +             */
  +            if (port == oldport &&
  +                ((!addr && !sa->hostname) ||
  +                 ((addr && sa->hostname) && !strcmp(sa->hostname,
addr)))) {
                   new = *walk;
                   *walk = new->next;
                   new->next = ap_listeners;
  @@ -271,10 +269,27 @@
                         addr);
           return "Listen setup failed";
       }
  -    if ((status = apr_socket_create(&new->sd,
  -                                    new->bind_addr->family,
  -                                    SOCK_STREAM, process->pool))
  -        != APR_SUCCESS) {
  +
  +    while (new->bind_addr) {
  +        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;
  +        }
  +        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";
  
  
  

Mime
View raw message