diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-04-21 17:14:44 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-04-21 18:39:26 -0700 |
commit | 638c1ee16147f40981cdfc785d520eb162dbcbea (patch) | |
tree | cc4d82988618bcd0c2c11708e278e45dbb72d13a | |
parent | 0c23f488948739e878969efce367f7270e76d9eb (diff) |
partial fix for #546
-rw-r--r-- | src/core/iomgr/tcp_server_windows.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/tcp_windows.c | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c index d1b02a6935..6e10da97cc 100644 --- a/src/core/iomgr/tcp_server_windows.c +++ b/src/core/iomgr/tcp_server_windows.c @@ -191,6 +191,8 @@ static void start_accept(server_port *port) { goto failure; } + /* TODO(jtattermusch): probably a race here, we regularly get use-after-free on server shutdown */ + GPR_ASSERT(port->socket != 0xfeeefeee); success = port->AcceptEx(port->socket->socket, sock, port->addresses, 0, addrlen, addrlen, &bytes_received, &port->socket->read_info.overlapped); @@ -244,7 +246,9 @@ static void on_accept(void *arg, int success) { } if (ep) sp->server->cb(sp->server->cb_arg, ep); - start_accept(sp); + if (success) { + start_accept(sp); + } } static int add_socket_to_server(grpc_tcp_server *s, SOCKET sock, diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c index 90fa877847..71534eaa3d 100644 --- a/src/core/iomgr/tcp_windows.c +++ b/src/core/iomgr/tcp_windows.c @@ -127,6 +127,7 @@ static void on_read(void *tcpp, int success) { if (socket->read_info.wsa_error != 0) { char *utf8_message = gpr_format_message(info->wsa_error); + gpr_log(GPR_ERROR, "ReadFile overlapped error: %s", utf8_message); gpr_free(utf8_message); status = GRPC_ENDPOINT_CB_ERROR; } else { |