From: Guus Sliepen Date: Thu, 27 Jul 2017 09:25:50 +0000 (+0200) Subject: Call the poll callback with len = 0 on errors. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=d3b3b958b5555dfe0e20844135bff1d8b838f1dc;p=utcp Call the poll callback with len = 0 on errors. --- diff --git a/utcp.c b/utcp.c index c650ab7..906068c 100644 --- a/utcp.c +++ b/utcp.c @@ -1427,8 +1427,15 @@ struct timeval utcp_timeout(struct utcp *utcp) { retransmit(c); } - if(c->poll && buffer_free(&c->sndbuf) && (c->state == ESTABLISHED || c->state == CLOSE_WAIT)) - c->poll(c, buffer_free(&c->sndbuf)); + if(c->poll) { + if((c->state == ESTABLISHED || c->state == CLOSE_WAIT)) { + uint32_t len = buffer_free(&c->sndbuf); + if(len) + c->poll(c, len); + } else if(c->state == CLOSED) { + c->poll(c, 0); + } + } if(timerisset(&c->conn_timeout) && timercmp(&c->conn_timeout, &next, <)) next = c->conn_timeout;