From d1e6be1460f555a1f8a4063d7642696aa7238769 Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Thu, 16 Jan 2014 03:06:50 -0800 Subject: [PATCH] tcp: reveal bind-time errors before listen Changed uv_tcp_duplicate_socket to reveal any bind-time errors before calling listen(). This fix is 100% windows specific. It helps fix Node.js unite test test-cluster-bind-twice on Windows. --- src/win/tcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/win/tcp.c b/src/win/tcp.c index 31526b68..5437e3df 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -1171,6 +1171,12 @@ int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, if (!(handle->flags & UV_HANDLE_BOUND)) { return ERROR_INVALID_PARAMETER; } + + /* Report any deferred bind errors now. */ + if (handle->flags & UV_HANDLE_BIND_ERROR) { + return handle->bind_error; + } + if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { return WSAGetLastError(); }