From 0cbad54f182fc9059fa54486cc464fcd99384c24 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 17 Apr 2017 19:12:56 -0400 Subject: [PATCH] udp: fix fast path in uv_udp_send() on unix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Fast" path in `uv_udp_send()` attempts to write the data straight away without queueing the fd with epoll/kqueue/... However, in some cases this is not possible when `sendmsg()` returns `EAGAIN`. In such event libuv has to queue the fd anyway. PR-URL: https://github.com/libuv/libuv/pull/1308 Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Santiago Gimeno --- src/unix/udp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/udp.c b/src/unix/udp.c index f9630c85..73f2bc4e 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c @@ -433,6 +433,13 @@ int uv__udp_send(uv_udp_send_t* req, if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) { uv__udp_sendmsg(handle); + + /* `uv__udp_sendmsg` may not be able to do non-blocking write straight + * away. In such cases the `io_watcher` has to be queued for asynchronous + * write. + */ + if (!QUEUE_EMPTY(&handle->write_queue)) + uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); } else { uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); }