]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use AF_UNSPEC not PF_UNSPEC in getaddrinfo calls.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:21:06 +0000 (13:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:21:42 +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/port/pipe.c

index 49a45941701aa68de68e71f343ab2a19fabf9240..1ba3915866e7f10075c60c8f41ae1847c10645ea 100644 (file)
@@ -822,7 +822,7 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
 
                        /* 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 536bcff6af22b277e1d066af61777dc6a7734b4e..39886b0a3c5147e6116237e5941ab257518739b1 100644 (file)
@@ -314,7 +314,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 9442444d9638622e1e2ce0be4a03f5e09dc190d2..855b81e24c37c1948ea37fa5b247bc66074ef765 100644 (file)
@@ -1199,7 +1199,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 4d04ba9da446ce79347acb787e2f72e0a76fc208..ae9fa5b4d66a6429ff41f52a8091ce1a8adb22fa 100644 (file)
@@ -55,7 +55,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)
        {
                ereport(LOG, (errmsg_internal("pgpipe failed to create socket 2: %ui", WSAGetLastError())));
                closesocket(s);