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 Fri, 15 Aug 2003 02:25:41 GMT
jerenkrantz    2003/08/14 19:25:41

  Modified:    .        CHANGES
               server   listen.c
  Log:
  Change Listen directive to bind to all addresses returned by
  apr_sockaddr_info_get when a hostname is not specified.
  
  Revision  Changes    Path
  1.1254    +4 -1      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1253
  retrieving revision 1.1254
  diff -u -u -r1.1253 -r1.1254
  --- CHANGES	13 Aug 2003 21:01:41 -0000	1.1253
  +++ CHANGES	15 Aug 2003 02:25:40 -0000	1.1254
  @@ -2,9 +2,12 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) Change Listen directive to bind to all addresses when a hostname is
  +     not specified.  [Justin Erenkrantz]
  +
     *) Correct failure with Listen directives on machines with IPv6 enabled.
        [Colm MacCárthaigh <colm@stdlib.net>, Justin Erenkrantz]
  -  
  +
     *) Fix a link failure in mod_ssl when the OpenSSL libraries contain
        the ENGINE functions but the engine header files are missing.
        [Cliff Woolley]
  
  
  
  1.89      +36 -23    httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -u -r1.88 -r1.89
  --- listen.c	14 Aug 2003 00:05:26 -0000	1.88
  +++ listen.c	15 Aug 2003 02:25:41 -0000	1.89
  @@ -232,16 +232,18 @@
   static const char *alloc_listener(process_rec *process, char *addr, apr_port_t port)
   {
       ap_listen_rec **walk;
  -    ap_listen_rec *new;
       apr_status_t status;
  -    apr_port_t oldport;
       apr_sockaddr_t *sa;
  +    int found_listener = 0;
   
       /* see if we've got an old listener for this address:port */
  -    for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
  +    for (walk = &old_listeners; *walk;) {
           sa = (*walk)->bind_addr;
           /* Some listeners are not real so they will not have a bind_addr. */
           if (sa) {
  +            ap_listen_rec *new;
  +            apr_port_t oldport;
  +
               apr_sockaddr_port_get(&oldport, sa);
               /* If both ports are equivalent, then if their names are equivalent,
                * then we will re-use the existing record.
  @@ -253,16 +255,20 @@
                   *walk = new->next;
                   new->next = ap_listeners;
                   ap_listeners = new;
  -                return NULL;
  +                found_listener = 1;
  +                continue;
               }
           }
  +
  +        walk = &(*walk)->next;
  +    }
  +
  +    if (found_listener) {
  +        return NULL;
       }
   
  -    /* this has to survive restarts */
  -    new = apr_palloc(process->pool, sizeof(ap_listen_rec));
  -    new->active = 0;
  -    if ((status = apr_sockaddr_info_get(&new->bind_addr, addr, APR_UNSPEC,
  -                                        port, 0, process->pool))
  +    if ((status = apr_sockaddr_info_get(&sa, addr, APR_UNSPEC, port, 0,
  +                                        process->pool))
           != APR_SUCCESS) {
           ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
                         "alloc_listener: failed to set up sockaddr for %s",
  @@ -270,33 +276,40 @@
           return "Listen setup failed";
       }
   
  -    while (new->bind_addr) {
  +    while (sa) {
  +        ap_listen_rec *new;
  +
  +        /* this has to survive restarts */
  +        new = apr_palloc(process->pool, sizeof(ap_listen_rec));
  +        new->active = 0;
  +        new->bind_addr = sa;
  +
  +        /* Go to the next sockaddr. */
  +        sa = sa->next;
  +
           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;
  +            continue;
           }
  -#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";
  +        }
   
  -    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";
  +        new->next = ap_listeners;
  +        ap_listeners = new;
       }
   
  -    new->next = ap_listeners;
  -    ap_listeners = new;
       return NULL;
   }
   
  
  
  

Mime
View raw message