]> git.meshlink.io Git - utcp/commitdiff
Avoid calling the poll callback for UDP style channels.
authorGuus Sliepen <guus@sliepen.org>
Mon, 13 Apr 2020 19:30:00 +0000 (21:30 +0200)
committerGuus Sliepen <guus@sliepen.org>
Mon, 13 Apr 2020 19:30:00 +0000 (21:30 +0200)
We still call it on connection establishment and on errors, but we don't
call it when we have space free in the send buffer.

utcp.c

diff --git a/utcp.c b/utcp.c
index 6279d925a781814eeb06710c406fa47063c2f052..aa1c50f79c965709276951f992fd3e681c6feb94 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -816,7 +816,6 @@ ssize_t utcp_send(struct utcp_connection *c, const void *data, size_t len) {
        if(!is_reliable(c)) {
                c->snd.una = c->snd.nxt = c->snd.last;
                buffer_discard(&c->sndbuf, c->sndbuf.used);
-               c->do_poll = true;
        }
 
        if(is_reliable(c) && !timespec_isset(&c->rtrx_timeout)) {
@@ -1594,7 +1593,10 @@ synack:
 
                if(data_acked) {
                        buffer_discard(&c->sndbuf, data_acked);
-                       c->do_poll = true;
+
+                       if(is_reliable(c)) {
+                               c->do_poll = true;
+                       }
                }
 
                // Also advance snd.nxt if possible
@@ -2318,7 +2320,7 @@ void utcp_set_sndbuf(struct utcp_connection *c, size_t size) {
                c->sndbuf.maxsize = -1;
        }
 
-       c->do_poll = buffer_free(&c->sndbuf);
+       c->do_poll = is_reliable(c) && buffer_free(&c->sndbuf);
 }
 
 size_t utcp_get_rcvbuf(struct utcp_connection *c) {
@@ -2386,7 +2388,7 @@ void utcp_set_recv_cb(struct utcp_connection *c, utcp_recv_t recv) {
 void utcp_set_poll_cb(struct utcp_connection *c, utcp_poll_t poll) {
        if(c) {
                c->poll = poll;
-               c->do_poll = buffer_free(&c->sndbuf);
+               c->do_poll = is_reliable(c) && buffer_free(&c->sndbuf);
        }
 }