From 3bd3f7a83d4685ca18f5eeb3aafc73b615698016 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 10 Jan 2009 18:36:59 +0100 Subject: [PATCH] Implement chunk queing for the udp sender. --- udp_send.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/udp_send.c b/udp_send.c index 7704b0a1..1408ae7f 100644 --- a/udp_send.c +++ b/udp_send.c @@ -76,13 +76,32 @@ static void udp_send_buf(char *buf, size_t len) list_for_each_entry_safe(ut, tmp, &targets, node) { if (ut->fd < 0) continue; - ret = write_nonblock(ut->fd, buf, len, len); + ret = send_queued_chunks(ut->fd, ut->cq, 0); if (ret < 0) { udp_delete_target(ut, para_strerror(-ret)); continue; } - if (ret != len) - PARA_WARNING_LOG("short write %zu/%zu\n", ret, len); + if (!len) + continue; + if (!ret) { /* still data left in the queue */ + ret = cq_enqueue(ut->cq, buf, len); + if (ret < 0) { + udp_delete_target(ut, para_strerror(-ret)); + continue; + } + } + ret = write_nonblock(ut->fd, buf, len, 0); + if (ret < 0) { + udp_delete_target(ut, para_strerror(-ret)); + continue; + } + if (ret != len) { + ret = cq_enqueue(ut->cq, buf + ret, len - ret); + if (ret < 0) { + udp_delete_target(ut, para_strerror(-ret)); + continue; + } + } } } -- 2.39.5