apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr/network_io/unix sockaddr.c
Date Wed, 13 Aug 2003 19:21:44 GMT
jerenkrantz    2003/08/13 12:21:44

  Modified:    .        CHANGES
               network_io/unix sockaddr.c
  Log:
  Modify apr_sockaddr_info_get to call the resolver when we do not have a
  hostname.  Also, fix bugs in the getaddrinfo() implementation which are
  present when a hostname is not available.
  
  (Justin modified Colm's patch to set servname when we do not have a hostname.
  RFC 2553 requires one of them to be non-NULL, and Solaris enforces that.)
  
  Submitted by:	Colm MacCárthaigh <colm@stdlib.net>
  Reviewed by:	Justin Erenkrantz
  
  Revision  Changes    Path
  1.423     +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.422
  retrieving revision 1.423
  diff -u -u -r1.422 -r1.423
  --- CHANGES	7 Aug 2003 23:20:02 -0000	1.422
  +++ CHANGES	13 Aug 2003 19:21:43 -0000	1.423
  @@ -1,5 +1,10 @@
   Changes with APR 0.9.4
   
  +  *) Modify apr_sockaddr_info_get to call the resolver when we
  +     do not have a hostname.  Also, fix bugs in the getaddrinfo()
  +     implementation.
  +     [Colm MacCárthaigh <colm@stdlib.net>, Justin Erenkrantz]
  +
     *) Change the behavior of unix process 'trylock's to return
        APR_ENOTIMPL instead of segfaulting, consistent with the
        other lock implementations.  [William Rowe]
  
  
  
  1.39      +20 -17    apr/network_io/unix/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockaddr.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -u -r1.38 -r1.39
  --- sockaddr.c	17 Jul 2003 14:27:39 -0000	1.38
  +++ sockaddr.c	13 Aug 2003 19:21:44 -0000	1.39
  @@ -369,6 +369,7 @@
       struct addrinfo hints, *ai, *ai_list;
       apr_sockaddr_t *prev_sa;
       int error;
  +    char *servname = NULL; 
   
       memset(&hints, 0, sizeof(hints));
       hints.ai_family = family;
  @@ -381,12 +382,23 @@
           hints.ai_flags = AI_ADDRCONFIG;
       }
   #endif
  -    error = getaddrinfo(hostname, NULL, &hints, &ai_list);
  +    if(hostname == NULL) {
  +#ifdef AI_PASSIVE 
  +        /* If hostname is NULL, assume we are trying to bind to all
  +         * interfaces. */
  +        hints.ai_flags |= AI_PASSIVE;
  +#endif
  +        /* getaddrinfo according to RFC 2553 must have either hostname
  +         * or servname non-NULL.
  +         */
  +        servname = apr_itoa(p, port);
  +    }
  +    error = getaddrinfo(hostname, servname, &hints, &ai_list);
   #ifdef AI_ADDRCONFIG
       if (error == EAI_BADFLAGS && family == AF_UNSPEC) {
           /* Retry with no flags if AI_ADDRCONFIG was rejected. */
           hints.ai_flags = 0;
  -        error = getaddrinfo(hostname, NULL, &hints, &ai_list);
  +        error = getaddrinfo(hostname, servname, &hints, &ai_list);
       }
   #endif
       if (error) {
  @@ -490,6 +502,11 @@
       struct in_addr ipaddr;
       char *addr_list[2];
   
  +    if (hostname == NULL) {
  +        /* if we are given a NULL hostname, assume '0.0.0.0' */
  +        hostname = "0.0.0.0";
  +    }
  +
       if (*hostname >= '0' && *hostname <= '9' &&
           strspn(hostname, "0123456789.") == strlen(hostname)) {
   
  @@ -580,21 +597,7 @@
   #endif
       }
       
  -    if (hostname) {
  -#if !APR_HAVE_IPV6
  -        if (family == APR_UNSPEC) {
  -            family = APR_INET;
  -        }
  -#endif
  -        return find_addresses(sa, hostname, family, port, flags, p);
  -    }
  -
  -    *sa = apr_pcalloc(p, sizeof(apr_sockaddr_t));
  -    (*sa)->pool = p;
  -    apr_sockaddr_vars_set(*sa, 
  -                          family == APR_UNSPEC ? APR_INET : family,
  -                          port);
  -    return APR_SUCCESS;
  +    return find_addresses(sa, hostname, family, port, flags, p);
   }
   
   APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
  
  
  

Mime
View raw message