From: Guus Sliepen Date: Fri, 25 Feb 2022 23:52:56 +0000 (+0100) Subject: Make AIO more useful for UDP-style channels. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=e44062ac74fd8255c870cff79e42f880dddff989;p=meshlink 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. --- 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; }