]> git.meshlink.io Git - meshlink/blobdiff - src/utcp.c
Ensure the flush timer is started if we never had any full packets to send.
[meshlink] / src / utcp.c
index cbc094a1cbe060658969cc145fdf17c62d4ecdf9..d068d45b20ccd01d4f9e1b43f01e7becac95cdc3 100644 (file)
@@ -880,6 +880,9 @@ static void ack_unreliable_framed(struct utcp_connection *c) {
                        // There is no partial data in the send buffer, so stop the flush timer
                        stop_retransmit_timer(c);
                }
+       } else if(left && !timespec_isset(&c->rtrx_timeout)) {
+               // We have partial data and we didn't start the flush timer yet
+               start_flush_timer(c);
        }
 }
 
@@ -2433,7 +2436,7 @@ struct timespec utcp_timeout(struct utcp *utcp) {
                if(c->poll) {
                        if((c->state == ESTABLISHED || c->state == CLOSE_WAIT) && c->do_poll) {
                                c->do_poll = false;
-                               uint32_t len = buffer_free(&c->sndbuf);
+                               uint32_t len = is_framed(c) ? min(buffer_free(&c->sndbuf), MAX_UNRELIABLE_SIZE) : buffer_free(&c->sndbuf);
 
                                if(len) {
                                        c->poll(c, len);