]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Avoid sending packets smaller than the MTU if we don't need to.
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index 7aeb2d358cf7b3157672f8bb2f25b488b9a40606..cb23e1bf3d6413510d8dd729f7dd00e781eb4291 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -521,10 +521,14 @@ static void ack(struct utcp_connection *c, bool sendatleastone) {
 
        assert(left >= 0);
 
-       if(cwndleft < 0) {
+       if(cwndleft <= 0) {
                left = 0;
        } else if(cwndleft < left) {
                left = cwndleft;
+
+               if(!sendatleastone || cwndleft > c->utcp->mtu) {
+                       left -= left % c->utcp->mtu;
+               }
        }
 
        debug("cwndleft = %d, left = %d\n", cwndleft, left);