Skip to content

Commit e6168df

Browse files
santigimenocjihrig
authored andcommitted
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: nodejs/node#14828 PR-URL: libuv#1739 Reviewed-By: Colin Ihrig <[email protected]>
1 parent a4b2e32 commit e6168df

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/unix/stream.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ struct uv__stream_select_s {
5858
fd_set* swrite;
5959
size_t swrite_sz;
6060
};
61+
# define WRITE_RETRY_ON_ERROR(send_handle) \
62+
(errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || \
63+
(errno == EMSGSIZE && send_handle))
64+
#else
65+
# define WRITE_RETRY_ON_ERROR(send_handle) \
66+
(errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
6167
#endif /* defined(__APPLE__) */
6268

6369
static void uv__stream_connect(uv_stream_t*);
@@ -859,7 +865,7 @@ static void uv__write(uv_stream_t* stream) {
859865
}
860866

861867
if (n < 0) {
862-
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) {
868+
if (!WRITE_RETRY_ON_ERROR(req->send_handle)) {
863869
err = UV__ERR(errno);
864870
goto error;
865871
} else if (stream->flags & UV_STREAM_BLOCKING) {

0 commit comments

Comments
 (0)