Skip to content

Commit

Permalink
osx,stream: retry sending handle on EMSGSIZE error
Browse files Browse the repository at this point in the history
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.
In that's the case, return control to the loop and try again in the next
iteration.

Fixes: nodejs/node#14828
  • Loading branch information
santigimeno committed Feb 19, 2018
1 parent 1ded669 commit 5414c11
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,16 @@ static void uv__write(uv_stream_t* stream) {
}

if (n < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) {
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS
#if defined(__APPLE__)
/*
* EMSGSIZE error happens when there isn't enough room in the socket output
* buffer to store the whole message. If that's the case, retry in the next
* loop iteration.
*/
&& !(errno == EMSGSIZE && req->send_handle)
#endif
) {
err = UV__ERR(errno);
goto error;
} else if (stream->flags & UV_STREAM_BLOCKING) {
Expand Down

0 comments on commit 5414c11

Please sign in to comment.