aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-08-27 18:44:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-08-27 18:44:03 +0000
commit9e56c5a4cff7edb145729c7ba2b19dd8cf1c45cf (patch)
tree50036ec5891b6351c62fb75a7b0c25787ac038f4
parent5a7d36973ad791b92a056ee10772378c161562c1 (diff)
downloadpostgresql-9e56c5a4cff7edb145729c7ba2b19dd8cf1c45cf.tar.gz
postgresql-9e56c5a4cff7edb145729c7ba2b19dd8cf1c45cf.zip
Windows needs WSAStartup() before getaddrinfo() will work. Andrew Dunstan
-rw-r--r--src/bin/initdb/initdb.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 6c6beb71cff..827d54c1f48 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.96 2005/08/25 02:22:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.97 2005/08/27 18:44:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1221,6 +1221,13 @@ setup_config(void)
{
struct addrinfo *gai_result;
struct addrinfo hints;
+ int err = 0;
+#ifdef WIN32
+ /* need to call WSAStartup before calling getaddrinfo */
+ WSADATA wsaData;
+
+ err = WSAStartup(MAKEWORD(2,2), &wsaData);
+#endif
/* for best results, this code should match parse_hba() */
hints.ai_flags = AI_NUMERICHOST;
@@ -1232,7 +1239,8 @@ setup_config(void)
hints.ai_addr = NULL;
hints.ai_next = NULL;
- if (getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
+ if (err != 0 ||
+ getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
conflines = replace_token(conflines,
"host all all ::1",
"#host all all ::1");