]> granicus.if.org Git - postgresql/commitdiff
Use AF_UNSPEC not PF_UNSPEC in getaddrinfo calls.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:20:54 +0000 (13:20 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:21:20 +0000 (13:21 -0400)
According to the Single Unix Spec and assorted man pages, you're supposed
to use the constants named AF_xxx when setting ai_family for a getaddrinfo
call.  In a few places we were using PF_xxx instead.  Use of PF_xxx
appears to be an ancient BSD convention that was not adopted by later
standardization.  On BSD and most later Unixen, it doesn't matter much
because those constants have equivalent values anyway; but nonetheless
this code is not per spec.

In the same vein, replace PF_INET by AF_INET in one socket() call, which
wasn't even consistent with the other socket() call in the same function
let alone the remainder of our code.

Per investigation of a Cygwin trouble report from Marco Atzeri.  It's
probably a long shot that this will fix his issue, but it's wrong in
any case.

src/backend/libpq/hba.c
src/backend/postmaster/pgstat.c
src/bin/initdb/initdb.c
src/bin/pg_dump/parallel.c

index 83dd14740818e201c4b44f3b183ed5872ffb81d8..b070bfeda353bb1793bf777a8b0f0712087bbfd4 100644 (file)
@@ -1041,7 +1041,7 @@ parse_hba_line(List *line, int line_num, char *raw_line)
 
                        /* Get the IP address either way */
                        hints.ai_flags = AI_NUMERICHOST;
-                       hints.ai_family = PF_UNSPEC;
+                       hints.ai_family = AF_UNSPEC;
                        hints.ai_socktype = 0;
                        hints.ai_protocol = 0;
                        hints.ai_addrlen = 0;
index e355cdee953718cb7a2d1c32525be2d16c2c99b0..479dfa7d3cfa24550ff921d04d76f8bcf5cd390e 100644 (file)
@@ -348,7 +348,7 @@ pgstat_init(void)
         * Create the UDP socket for sending and receiving statistic messages
         */
        hints.ai_flags = AI_PASSIVE;
-       hints.ai_family = PF_UNSPEC;
+       hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_DGRAM;
        hints.ai_protocol = 0;
        hints.ai_addrlen = 0;
index b1dd1fe52fda410f4856f50b821e2da57924d8ea..55083b254df614eea2eab7c4de3bf395d7edc1c4 100644 (file)
@@ -1354,7 +1354,7 @@ setup_config(void)
 
                /* for best results, this code should match parse_hba() */
                hints.ai_flags = AI_NUMERICHOST;
-               hints.ai_family = PF_UNSPEC;
+               hints.ai_family = AF_UNSPEC;
                hints.ai_socktype = 0;
                hints.ai_protocol = 0;
                hints.ai_addrlen = 0;
index 7d6e146dbda831d1cc50697bad37900d0cdf679a..afe941f80b859d463b4a2444e296163ed7a8f8e6 100644 (file)
@@ -1363,7 +1363,7 @@ pgpipe(int handles[2])
                closesocket(s);
                return -1;
        }
-       if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+       if ((handles[1] = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
        {
                write_msg(modulename, "pgpipe: could not create second socket: error code %d\n",
                                  WSAGetLastError());