From d3b3b958b5555dfe0e20844135bff1d8b838f1dc Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 27 Jul 2017 11:25:50 +0200 Subject: [PATCH] Call the poll callback with len = 0 on errors. --- utcp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; -- 2.39.2