Skip to content

Commit 661ad7f

Browse files
committed
We need the iomgr_init for winsocks initialization.
Also fixed (thanks @nicolasnoble) wrong construction of error msg.
1 parent 706b70f commit 661ad7f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core/iomgr/resolve_address_windows.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <grpc/support/alloc.h>
4949
#include <grpc/support/host_port.h>
5050
#include <grpc/support/log.h>
51+
#include <grpc/support/log_win32.h>
5152
#include <grpc/support/string_util.h>
5253
#include <grpc/support/thd.h>
5354
#include <grpc/support/time.h>
@@ -94,7 +95,9 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
9495
s = getaddrinfo(host, port, &hints, &result);
9596
GRPC_SCHEDULING_END_BLOCKING_REGION;
9697
if (s != 0) {
97-
gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s));
98+
char *error_message = gpr_format_message(s);
99+
gpr_log(GPR_ERROR, "getaddrinfo: %s", error_message);
100+
gpr_free(error_message);
98101
goto done;
99102
}
100103

test/core/iomgr/resolve_address_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ static void test_unparseable_hostports(void) {
126126
int main(int argc, char **argv) {
127127
grpc_test_init(argc, argv);
128128
grpc_executor_init();
129+
grpc_iomgr_init();
129130
test_localhost();
130131
test_default_port();
131132
test_missing_default_port();
132133
test_ipv6_with_port();
133134
test_ipv6_without_port();
134135
test_invalid_ip_addresses();
135136
test_unparseable_hostports();
137+
grpc_iomgr_shutdown();
136138
grpc_executor_shutdown();
137139
return 0;
138140
}

0 commit comments

Comments
 (0)