win,tcp: handle canceled connect with ECANCELED

This aligns Windows behavior with Unix.

Refs: https://github.com/JuliaLang/julia/pull/26545
PR-URL: https://github.com/libuv/libuv/pull/1783
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Jameson Nash 2018-03-21 17:29:44 -04:00 committed by cjihrig
parent 67a00e27c1
commit 5074a57989
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -1171,11 +1171,14 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
err = 0;
if (REQ_SUCCESS(req)) {
if (setsockopt(handle->socket,
SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT,
NULL,
0) == 0) {
if (handle->flags & UV__HANDLE_CLOSING) {
/* use UV_ECANCELED for consistency with Unix */
err = ERROR_OPERATION_ABORTED;
} else if (setsockopt(handle->socket,
SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT,
NULL,
0) == 0) {
uv_connection_init((uv_stream_t*)handle);
handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE;
loop->active_tcp_streams++;