From 6530ea2ff243161b4208aed9549fe2e4c6acc563 Mon Sep 17 00:00:00 2001 From: Supragya Raj Date: Thu, 5 Aug 2021 15:27:26 +0530 Subject: [PATCH] drop only successfully sent packets post sendmmsg sendmmsg returns with number of packets sent which can be less than number of packets requested to be sent. Do not flush entire write queue and use the returned info to partially clear the write queue. Refs: https://github.com/libuv/libuv/issues/3129 (fixes one issue listed) PR-URL: https://github.com/libuv/libuv/pull/3265 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- src/unix/udp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/udp.c b/src/unix/udp.c index 49051c07..8e718ced 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c @@ -375,8 +375,11 @@ write_queue_drain: return; } + /* Safety: npkts known to be >0 below. Hence cast from ssize_t + * to size_t safe. + */ for (i = 0, q = QUEUE_HEAD(&handle->write_queue); - i < pkts && q != &handle->write_queue; + i < (size_t)npkts && q != &handle->write_queue; ++i, q = QUEUE_HEAD(&handle->write_queue)) { assert(q != NULL); req = QUEUE_DATA(q, uv_udp_send_t, queue);