Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 65083 invoked by uid 500); 13 Aug 2003 19:21:35 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 65071 invoked from network); 13 Aug 2003 19:21:34 -0000 Date: 13 Aug 2003 19:21:44 -0000 Message-ID: <20030813192144.1393.qmail@minotaur.apache.org> From: jerenkrantz@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/network_io/unix sockaddr.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 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 , 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,