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{
12221222struct addrinfo * gai_result ;
12231223struct 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() */
12261233hints .ai_flags = AI_NUMERICHOST ;
@@ -1232,7 +1239,8 @@ setup_config(void)
12321239hints .ai_addr = NULL ;
12331240hints .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 )
12361244conflines = replace_token (conflines ,
12371245"host all all ::1" ,
12381246"#host all all ::1" );