From 4f913b669adc1765829ce57b8a022394e363a757 Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Tue, 18 Feb 2014 09:50:49 -0800 Subject: [PATCH] windows: freeze in uv_tcp_endgame The event_handle field of unused accept requests was not being initialized properly. As a result, uv_tcp_endgame would try to close an invalid handle and this could lead to unexpected behavior. This fixes node.js test test-cluster-disconnect.js on Windows. --- src/win/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/win/tcp.c b/src/win/tcp.c index 59a36de0..a91c5784 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -577,6 +577,7 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { req->accept_socket = INVALID_SOCKET; req->data = handle; req->wait_handle = INVALID_HANDLE_VALUE; + req->event_handle = NULL; } } @@ -1040,9 +1041,11 @@ void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, if (handle->flags & UV_HANDLE_EMULATE_IOCP) { if (req->wait_handle != INVALID_HANDLE_VALUE) { UnregisterWait(req->wait_handle); + req->wait_handle = INVALID_HANDLE_VALUE; } if (req->event_handle) { CloseHandle(req->event_handle); + req->event_handle = NULL; } }