Skip to content

Commit bac05d6

Browse files
committed
Use AF_UNSPEC not PF_UNSPEC in getaddrinfo calls.
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.
1 parent b764080 commit bac05d6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/backend/libpq/hba.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ parse_hba_line(List *line, int line_num)
10151015

10161016
/* Get the IP address either way */
10171017
hints.ai_flags = AI_NUMERICHOST;
1018-
hints.ai_family = PF_UNSPEC;
1018+
hints.ai_family = AF_UNSPEC;
10191019
hints.ai_socktype = 0;
10201020
hints.ai_protocol = 0;
10211021
hints.ai_addrlen = 0;

src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pgstat_init(void)
319319
* Create the UDP socket for sending and receiving statistic messages
320320
*/
321321
hints.ai_flags = AI_PASSIVE;
322-
hints.ai_family = PF_UNSPEC;
322+
hints.ai_family = AF_UNSPEC;
323323
hints.ai_socktype = SOCK_DGRAM;
324324
hints.ai_protocol = 0;
325325
hints.ai_addrlen = 0;

src/bin/initdb/initdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ setup_config(void)
11081108

11091109
/* for best results, this code should match parse_hba() */
11101110
hints.ai_flags = AI_NUMERICHOST;
1111-
hints.ai_family = PF_UNSPEC;
1111+
hints.ai_family = AF_UNSPEC;
11121112
hints.ai_socktype = 0;
11131113
hints.ai_protocol = 0;
11141114
hints.ai_addrlen = 0;

0 commit comments

Comments
 (0)