openbsd,tcp: special handling of EINVAL on connect

Map `EINVAL` to `ECONNREFUSED` and return error on the next tick.

Fixes: https://github.com/libuv/libuv/issues/2155
PR-URL: https://github.com/libuv/libuv/pull/2154
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
ptlomholt 2019-01-17 11:05:35 -08:00 committed by Santiago Gimeno
parent f66eda7cba
commit 110eb817bd
No known key found for this signature in database
GPG Key ID: F28C3C8DA33C03BE

View File

@ -235,12 +235,16 @@ int uv__tcp_connect(uv_connect_t* req,
if (r == -1 && errno != 0) { if (r == -1 && errno != 0) {
if (errno == EINPROGRESS) if (errno == EINPROGRESS)
; /* not an error */ ; /* not an error */
else if (errno == ECONNREFUSED) else if (errno == ECONNREFUSED
/* If we get a ECONNREFUSED wait until the next tick to report the #if defined(__OpenBSD__)
* error. Solaris wants to report immediately--other unixes want to || errno == EINVAL
* wait. #endif
)
/* If we get ECONNREFUSED (Solaris) or EINVAL (OpenBSD) wait until the
* next tick to report the error. Solaris and OpenBSD wants to report
* immediately -- other unixes want to wait.
*/ */
handle->delayed_error = UV__ERR(errno); handle->delayed_error = UV__ERR(ECONNREFUSED);
else else
return UV__ERR(errno); return UV__ERR(errno);
} }