From 8a9585232e9df227bcaf1263748d8997ec5d1077 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Sat, 30 Sep 2017 18:33:32 +0200 Subject: [PATCH] unix: retry on ENOBUFS in sendmsg(2) libuv retries when sendmsg(2) fails with EAGAIN or EWOULDBLOCK. This commit adds similar functionality for ENOBUFS. PR-URL: https://github.com/libuv/libuv/pull/1573 Reviewed-By: Santiago Gimeno Reviewed-By: Ben Noordhuis --- src/unix/stream.c | 2 +- src/unix/udp.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index c502098d..672a7e2d 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -859,7 +859,7 @@ start: } if (n < 0) { - if (errno != EAGAIN && errno != EWOULDBLOCK) { + if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) { err = -errno; goto error; } else if (stream->flags & UV_STREAM_BLOCKING) { diff --git a/src/unix/udp.c b/src/unix/udp.c index c556325d..a475bf57 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c @@ -237,8 +237,10 @@ static void uv__udp_sendmsg(uv_udp_t* handle) { size = sendmsg(handle->io_watcher.fd, &h, 0); } while (size == -1 && errno == EINTR); - if (size == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) - break; + if (size == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) + break; + } req->status = (size == -1 ? -errno : size); @@ -472,7 +474,7 @@ int uv__udp_try_send(uv_udp_t* handle, } while (size == -1 && errno == EINTR); if (size == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) return -EAGAIN; else return -errno;