Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 33af087

Browse filesBrowse files
committed
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.
1 parent 0549ba8 commit 33af087
Copy full SHA for 33af087

File tree

Expand file treeCollapse file tree

1 file changed

+29
-8
lines changed
Filter options
  • src/backend/libpq
Expand file treeCollapse file tree

1 file changed

+29
-8
lines changed

‎src/backend/libpq/ip.c

Copy file name to clipboardExpand all lines: src/backend/libpq/ip.c
+29-8Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.37 2006/10/19 17:26:32 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.38 2006/10/19 23:17:39 tgl Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -64,6 +64,8 @@ int
6464
pg_getaddrinfo_all(const char *hostname, const char *servname,
6565
const struct addrinfo * hintp, struct addrinfo ** result)
6666
{
67+
int rc;
68+
6769
/* not all versions of getaddrinfo() zero *result on failure */
6870
*result = NULL;
6971

@@ -72,18 +74,37 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
7274
return getaddrinfo_unix(servname, hintp, result);
7375
#endif
7476

77+
/* NULL has special meaning to getaddrinfo(). */
78+
rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
79+
servname, hintp, result);
80+
7581
#ifdef _AIX
7682
/*
77-
* It seems AIX's getaddrinfo doesn't reliably zero sin_port when servname
78-
* is NULL, so force the issue.
83+
* It seems some versions of AIX's getaddrinfo don't reliably zero
84+
* sin_port when servname is NULL, so clean up after it.
7985
*/
80-
if (servname == NULL)
81-
servname = "0";
86+
if (servname == NULL && rc == 0)
87+
{
88+
struct addrinfo *addr;
89+
90+
for (addr = *result; addr; addr = addr->ai_next)
91+
{
92+
switch (addr->ai_family)
93+
{
94+
case AF_INET:
95+
((struct sockaddr_in *) addr->ai_addr)->sin_port = htons(0);
96+
break;
97+
#ifdef HAVE_IPV6
98+
case AF_INET6:
99+
((struct sockaddr_in6 *) addr->ai_addr)->sin6_port = htons(0);
100+
break;
101+
#endif
102+
}
103+
}
104+
}
82105
#endif
83106

84-
/* NULL has special meaning to getaddrinfo(). */
85-
return getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
86-
servname, hintp, result);
107+
return rc;
87108
}
88109

89110

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.