osx,stream: retry sending handle on EMSGSIZE error

On OSX when sending handles via `sendmsg()` it can return `EMSGSIZE` if
there isn't room in the socket output buffer to store the whole message.
If that's the case, return control to the loop and try again in the next
iteration.

Fixes: https://github.com/nodejs/node/issues/14828
PR-URL: https://github.com/libuv/libuv/pull/1739
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Santiago Gimeno 2018-02-13 16:01:43 +01:00 committed by cjihrig
parent a4b2e32228
commit e6168df520
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -58,6 +58,12 @@ struct uv__stream_select_s {
fd_set* swrite;
size_t swrite_sz;
};
# define WRITE_RETRY_ON_ERROR(send_handle) \
(errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || \
(errno == EMSGSIZE && send_handle))
#else
# define WRITE_RETRY_ON_ERROR(send_handle) \
(errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
#endif /* defined(__APPLE__) */
static void uv__stream_connect(uv_stream_t*);
@ -859,7 +865,7 @@ start:
}
if (n < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) {
if (!WRITE_RETRY_ON_ERROR(req->send_handle)) {
err = UV__ERR(errno);
goto error;
} else if (stream->flags & UV_STREAM_BLOCKING) {