Try to fix the AIX getaddrinfo mess in a way that works on all versions.
Going to wait for buildfarm results before backpatching, this time.
This commit is contained in:
parent
0549ba82e3
commit
33af087695
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.37 2006/10/19 17:26:32 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.38 2006/10/19 23:17:39 tgl Exp $
|
||||||
*
|
*
|
||||||
* This file and the IPV6 implementation were initially provided by
|
* This file and the IPV6 implementation were initially provided by
|
||||||
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
|
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
|
||||||
@ -64,6 +64,8 @@ int
|
|||||||
pg_getaddrinfo_all(const char *hostname, const char *servname,
|
pg_getaddrinfo_all(const char *hostname, const char *servname,
|
||||||
const struct addrinfo * hintp, struct addrinfo ** result)
|
const struct addrinfo * hintp, struct addrinfo ** result)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* not all versions of getaddrinfo() zero *result on failure */
|
/* not all versions of getaddrinfo() zero *result on failure */
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
|
||||||
@ -72,18 +74,37 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
|
|||||||
return getaddrinfo_unix(servname, hintp, result);
|
return getaddrinfo_unix(servname, hintp, result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* NULL has special meaning to getaddrinfo(). */
|
||||||
|
rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
|
||||||
|
servname, hintp, result);
|
||||||
|
|
||||||
#ifdef _AIX
|
#ifdef _AIX
|
||||||
/*
|
/*
|
||||||
* It seems AIX's getaddrinfo doesn't reliably zero sin_port when servname
|
* It seems some versions of AIX's getaddrinfo don't reliably zero
|
||||||
* is NULL, so force the issue.
|
* sin_port when servname is NULL, so clean up after it.
|
||||||
*/
|
*/
|
||||||
if (servname == NULL)
|
if (servname == NULL && rc == 0)
|
||||||
servname = "0";
|
{
|
||||||
|
struct addrinfo *addr;
|
||||||
|
|
||||||
|
for (addr = *result; addr; addr = addr->ai_next)
|
||||||
|
{
|
||||||
|
switch (addr->ai_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
((struct sockaddr_in *) addr->ai_addr)->sin_port = htons(0);
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
case AF_INET6:
|
||||||
|
((struct sockaddr_in6 *) addr->ai_addr)->sin6_port = htons(0);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* NULL has special meaning to getaddrinfo(). */
|
return rc;
|
||||||
return getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
|
|
||||||
servname, hintp, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user