Skip to content

Commit 1794f4b

Browse files
committed
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. In that's the case, return control to the loop and try again in the next iteration. Fixes: nodejs/node#14828
1 parent 733adae commit 1794f4b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/unix/stream.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,16 @@ static void uv__write(uv_stream_t* stream) {
859859
}
860860

861861
if (n < 0) {
862-
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) {
862+
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS
863+
#if defined(__APPLE__)
864+
/*
865+
* EMSGSIZE error happens when there isn't enough room in the socket output
866+
* buffer to store the whole message. If that's the case, retry in the next
867+
* loop iteration.
868+
*/
869+
&& !(errno == EMSGSIZE && req->send_handle)
870+
#endif
871+
) {
863872
err = UV__ERR(errno);
864873
goto error;
865874
} else if (stream->flags & UV_STREAM_BLOCKING) {

0 commit comments

Comments
 (0)