Skip to content

Commit 234283e

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 96752b0 commit 234283e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/backend/libpq/hba.c

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

823823
/* Get the IP address either way */
824824
hints.ai_flags = AI_NUMERICHOST;
825-
hints.ai_family = PF_UNSPEC;
825+
hints.ai_family = AF_UNSPEC;
826826
hints.ai_socktype = 0;
827827
hints.ai_protocol = 0;
828828
hints.ai_addrlen = 0;

src/backend/postmaster/pgstat.c

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

src/bin/initdb/initdb.c

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

12001200
/* for best results, this code should match parse_hba() */
12011201
hints.ai_flags = AI_NUMERICHOST;
1202-
hints.ai_family = PF_UNSPEC;
1202+
hints.ai_family = AF_UNSPEC;
12031203
hints.ai_socktype = 0;
12041204
hints.ai_protocol = 0;
12051205
hints.ai_addrlen = 0;

src/port/pipe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pgpipe(int handles[2])
5555
closesocket(s);
5656
return -1;
5757
}
58-
if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
58+
if ((handles[1] = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
5959
{
6060
ereport(LOG, (errmsg_internal("pgpipe failed to create socket 2: %ui", WSAGetLastError())));
6161
closesocket(s);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy