X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=utcp.c;h=db775a9e8a5b37cc3e15c2ff06bf8cc4236c4260;hb=2ae2f9bbb7502589f279c329815d55ec526baffd;hp=391706f1d1abdee0ecf8a8edf7b2dc45f6cdd40d;hpb=b4e6d4bac314221a8bdb522daef24b606f143cee;p=utcp diff --git a/utcp.c b/utcp.c index 391706f..db775a9 100644 --- a/utcp.c +++ b/utcp.c @@ -587,12 +587,13 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) { #endif if(!acceptable) { - debug("Packet not acceptable, %u <= %u + %zu < %u\n", c->rcv.nxt, hdr.seq, len, c->rcv.nxt + c->rcv.wnd); + debug("Packet not acceptable, %u <= %u + %zu < %u\n", c->rcv.nxt, hdr.seq, len, c->rcv.nxt + c->rcv.wnd); // Ignore unacceptable RST packets. if(hdr.ctl & RST) return 0; // Otherwise, send an ACK back in the hope things improve. - goto ack; + ack(c, true); + return 0; } c->snd.wnd = hdr.wnd; // TODO: move below @@ -1061,7 +1062,7 @@ static void retransmit(struct utcp_connection *c) { * The return value is the time to the next timeout in milliseconds, * or maybe a negative value if the timeout is infinite. */ -int utcp_timeout(struct utcp *utcp) { +struct timeval utcp_timeout(struct utcp *utcp) { struct timeval now; gettimeofday(&now, NULL); struct timeval next = {now.tv_sec + 3600, now.tv_usec}; @@ -1111,9 +1112,7 @@ int utcp_timeout(struct utcp *utcp) { struct timeval diff; timersub(&next, &now, &diff); - if(diff.tv_sec < 0) - return 0; - return diff.tv_sec * 1000 + diff.tv_usec / 1000; + return diff; } struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_send_t send, void *priv) {