42
42
* Portions Copyright (c) 1994, Regents of the University of California
43
43
* Portions taken from FreeBSD.
44
44
*
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 $
46
46
*
47
47
*-------------------------------------------------------------------------
48
48
*/
@@ -1221,6 +1221,13 @@ setup_config(void)
1221
1221
{
1222
1222
struct addrinfo * gai_result ;
1223
1223
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
1224
1231
1225
1232
/* for best results, this code should match parse_hba() */
1226
1233
hints .ai_flags = AI_NUMERICHOST ;
@@ -1232,7 +1239,8 @@ setup_config(void)
1232
1239
hints .ai_addr = NULL ;
1233
1240
hints .ai_next = NULL ;
1234
1241
1235
- if (getaddrinfo ("::1" ,NULL ,& hints ,& gai_result )!= 0 )
1242
+ if (err != 0 ||
1243
+ getaddrinfo ("::1" ,NULL ,& hints ,& gai_result )!= 0 )
1236
1244
conflines = replace_token (conflines ,
1237
1245
"host all all ::1" ,
1238
1246
"#host all all ::1" );