Skip to content

Commit 9e56c5a

Browse files
committed
Windows needs WSAStartup() before getaddrinfo() will work. Andrew Dunstan
1 parent 5a7d369 commit 9e56c5a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/bin/initdb/initdb.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.96 2005/08/25 02:22:59 tgl Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.97 2005/08/27 18:44:03 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1221,6 +1221,13 @@ setup_config(void)
12211221
{
12221222
struct addrinfo *gai_result;
12231223
struct addrinfo hints;
1224+
int err = 0;
1225+
#ifdef WIN32
1226+
/* need to call WSAStartup before calling getaddrinfo */
1227+
WSADATA wsaData;
1228+
1229+
err = WSAStartup(MAKEWORD(2,2), &wsaData);
1230+
#endif
12241231

12251232
/* for best results, this code should match parse_hba() */
12261233
hints.ai_flags = AI_NUMERICHOST;
@@ -1232,7 +1239,8 @@ setup_config(void)
12321239
hints.ai_addr = NULL;
12331240
hints.ai_next = NULL;
12341241

1235-
if (getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
1242+
if (err != 0 ||
1243+
getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
12361244
conflines = replace_token(conflines,
12371245
"host all all ::1",
12381246
"#host all all ::1");

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