Work around reported problem that AIX's getaddrinfo() doesn't seem to zero
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Oct 2006 17:26:37 +0000 (17:26 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Oct 2006 17:26:37 +0000 (17:26 +0000)
sin_port in the returned IP address struct when servname is NULL.  This has
been observed to cause failure to bind the stats collection socket, and
could perhaps cause other issues too.  Per reports from Brad Nicholson
and Chris Browne.

src/backend/libpq/ip.c

index a45d0f48d2cfcf09bdd39deb5c33677f354bbfaa..5ce34a5b581bb0bbabc686fdfe986bc4912092c9 100644 (file)
@@ -75,6 +75,15 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
                return getaddrinfo_unix(servname, hintp, result);
 #endif
 
+#ifdef _AIX
+       /*
+        * It seems AIX's getaddrinfo doesn't reliably zero sin_port when servname
+        * is NULL, so force the issue.
+        */
+       if (servname == NULL)
+               servname = "0";
+#endif
+
        /* NULL has special meaning to getaddrinfo(). */
        return getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
                                           servname, hintp, result);