unix,stream: fix getsockopt error handling in connect

Fixes: https://github.com/libuv/libuv/issues/5086
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
Juan José Arboleda 2026-03-28 16:05:00 -05:00
parent 901e28384b
commit 46221faa63

View File

@ -1264,12 +1264,15 @@ static void uv__stream_connect(uv_stream_t* stream) {
} else {
/* Normal situation: we need to get the socket error from the kernel. */
assert(uv__stream_fd(stream) >= 0);
getsockopt(uv__stream_fd(stream),
SOL_SOCKET,
SO_ERROR,
&error,
&errorsize);
error = UV__ERR(error);
if (getsockopt(uv__stream_fd(stream),
SOL_SOCKET,
SO_ERROR,
&error,
&errorsize)) {
error = UV__ERR(errno);
} else {
error = UV__ERR(error);
}
}
if (error == UV__ERR(EINPROGRESS))