]> 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:58 +0000 (13:20 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:21:26 +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 ccc408231c81608f8758bc72c0dd65fbd25d1b4f..b288fb8f2e0d0024a8e0d9211917fcae3dff180b 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 1b8b6c73573c3a4c3a1f6a3176691126f1680163..ea3d2d7657b26df619f0a1ff11bf6d9e5d175342 100644 (file)
@@ -332,7 +332,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 c440f8f3a18e5548b3fe9b19c6dfa88dd3c53be6..0d867bba135d20a3678678cd49c4c2f8536a1ca8 100644 (file)
@@ -1306,7 +1306,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 ff777d2b4f4194f90e5dd36e8bd40fcd9477b42a..652dfd9256bab2325bb9b50d9543b9c1828bc534 100644 (file)
@@ -1360,7 +1360,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());