udp: fix fast path in uv_udp_send() on unix

"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é <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
Fedor Indutny 2017-04-17 19:12:56 -04:00
parent 8fd1e40606
commit 0cbad54f18

View File

@ -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);
}