]> 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:21:00 +0000 (13:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2014 17:21:31 +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

index 09e8715c798ec24c8596e78ef45f930f350109e6..1a562cbdb99a4e0d34cb9ed1ae547b5ca4c95bf0 100644 (file)
@@ -1015,7 +1015,7 @@ parse_hba_line(List *line, int line_num)
 
                        /* 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 214d1849a133e65709c4cba7c121f7ac6f798feb..c2fa6013d3a4b5c53d3d050b87dd85a81b68401a 100644 (file)
@@ -319,7 +319,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 3ed16d62b53e67ad202ea4449ed9b3ebe7e35841..cb0f021aac2b8fb495e69344823fce13cbd720b8 100644 (file)
@@ -1108,7 +1108,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;