X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=utcp.c;h=13f46584484bef5fd71ae74a77792671c1fb7637;hb=16ecd6d75bfabb97193581bcc8095652759cdb8e;hp=026fb31bf340f74db204ab1f68ad6cfe27c4977c;hpb=4e0031cf31b22f6cff80969c3e6e11c3c3001b04;p=utcp diff --git a/utcp.c b/utcp.c index 026fb31..13f4658 100644 --- a/utcp.c +++ b/utcp.c @@ -173,7 +173,7 @@ static ssize_t buffer_put_at(struct buffer *buf, size_t offset, const void *data } else { do { newsize *= 2; - } while(newsize < buf->used + len); + } while(newsize < required); } if(newsize > buf->maxsize) newsize = buf->maxsize; @@ -857,8 +857,10 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) { // In case this is for a CLOSED connection, ignore the packet. // TODO: make it so incoming packets can never match a CLOSED connection. - if(c->state == CLOSED) + if(c->state == CLOSED) { + debug("Got packet for closed connection\n"); return 0; + } // It is for an existing connection.