From 661ad7fc85b0603c9e554b82851c102b84375074 Mon Sep 17 00:00:00 2001
From: David Garcia Quintas <dgq@google.com>
Date: Tue, 13 Oct 2015 15:51:31 -0700
Subject: [PATCH] We need the iomgr_init for winsocks initialization.

Also fixed (thanks @nicolasnoble) wrong construction of error msg.
---
 src/core/iomgr/resolve_address_windows.c | 5 ++++-
 test/core/iomgr/resolve_address_test.c   | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/core/iomgr/resolve_address_windows.c b/src/core/iomgr/resolve_address_windows.c
index 6dc5de1660..007c855d10 100644
--- a/src/core/iomgr/resolve_address_windows.c
+++ b/src/core/iomgr/resolve_address_windows.c
@@ -48,6 +48,7 @@
 #include <grpc/support/alloc.h>
 #include <grpc/support/host_port.h>
 #include <grpc/support/log.h>
+#include <grpc/support/log_win32.h>
 #include <grpc/support/string_util.h>
 #include <grpc/support/thd.h>
 #include <grpc/support/time.h>
@@ -94,7 +95,9 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
   s = getaddrinfo(host, port, &hints, &result);
   GRPC_SCHEDULING_END_BLOCKING_REGION;
   if (s != 0) {
-    gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s));
+    char *error_message = gpr_format_message(s);
+    gpr_log(GPR_ERROR, "getaddrinfo: %s", error_message);
+    gpr_free(error_message);
     goto done;
   }
 
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
index a516a2595d..56ce091a88 100644
--- a/test/core/iomgr/resolve_address_test.c
+++ b/test/core/iomgr/resolve_address_test.c
@@ -126,6 +126,7 @@ static void test_unparseable_hostports(void) {
 int main(int argc, char **argv) {
   grpc_test_init(argc, argv);
   grpc_executor_init();
+  grpc_iomgr_init();
   test_localhost();
   test_default_port();
   test_missing_default_port();
@@ -133,6 +134,7 @@ int main(int argc, char **argv) {
   test_ipv6_without_port();
   test_invalid_ip_addresses();
   test_unparseable_hostports();
+  grpc_iomgr_shutdown();
   grpc_executor_shutdown();
   return 0;
 }
-- 
GitLab