]> git.meshlink.io Git - utcp/commitdiff
Call the poll callback with len = 0 on errors.
authorGuus Sliepen <guus@meshlink.io>
Thu, 27 Jul 2017 09:25:50 +0000 (11:25 +0200)
committerGuus Sliepen <guus@meshlink.io>
Thu, 27 Jul 2017 09:25:50 +0000 (11:25 +0200)
utcp.c

diff --git a/utcp.c b/utcp.c
index c650ab700ad150fa876b0944a6872ea39298f352..906068c0125c8c25b91bcf0b6a6585d97ee64c24 100644 (file)
--- 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;