]> git.meshlink.io Git - meshlink/commitdiff
Make AIO more useful for UDP-style channels.
authorGuus Sliepen <guus@meshlink.io>
Fri, 25 Feb 2022 23:52:56 +0000 (00:52 +0100)
committerGuus Sliepen <guus@meshlink.io>
Sat, 26 Feb 2022 00:00:55 +0000 (01:00 +0100)
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
src/utcp.c

index a5bf2c90ac3f6f33916d8eafceadb98a24f56ebd..35640eb91f6cb7871c514583cab3e6baaf1adcdc 100644 (file)
@@ -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 {
index ca91bee26ef6d21c0f0f57dd743c27c0f9b14f8b..221b6933485adef3c9dcb199343e7a2bbcbc8fbb 100644 (file)
@@ -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;
        }