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.
This commit is contained in:
Alexis Campailla 2014-01-16 03:06:50 -08:00 committed by Fedor Indutny
parent acb9f8951e
commit d1e6be1460

View File

@ -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();
}