From e44062ac74fd8255c870cff79e42f880dddff989 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 26 Feb 2022 00:52:56 +0100 Subject: [PATCH] Make AIO more useful for UDP-style channels. When doing AIO on a UDP-style channel, only try to send up to one MTU at a time. Also ensure that the poll callback is triggered every time something is sent on UDP channels, since the AIO code relies heavily on the poll callback to work. --- src/meshlink.c | 8 ++++++++ src/utcp.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/meshlink.c b/src/meshlink.c index a5bf2c90..35640eb9 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -4115,6 +4115,14 @@ static void channel_poll(struct utcp_connection *connection, size_t len) { todo = len; } + if(connection->flags == UTCP_UDP) { + size_t pmtu = utcp_get_mtu(connection->utcp); + + if(todo > pmtu) { + todo = pmtu; + } + } + if(aio->data) { sent = utcp_send(connection, (char *)aio->data + aio->done, todo); } else { diff --git a/src/utcp.c b/src/utcp.c index ca91bee2..221b6933 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -891,6 +891,8 @@ ssize_t utcp_send(struct utcp_connection *c, const void *data, size_t len) { errno = EMSGSIZE; return -1; } + + c->do_poll = true; } else { return 0; } -- 2.39.5