]> git.meshlink.io Git - utcp/commitdiff
Disable callbacks when closing a connection.
authorGuus Sliepen <guus@meshlink.io>
Tue, 2 Dec 2014 16:14:13 +0000 (17:14 +0100)
committerGuus Sliepen <guus@meshlink.io>
Tue, 2 Dec 2014 16:14:13 +0000 (17:14 +0100)
When an application calls utcp_close() on a previously established
connection, the utcp_connection is kept around to handle FIN(ACK)
packets. However, the peer could still send some data, which should not
trigger the receive callback.

utcp.c

diff --git a/utcp.c b/utcp.c
index a79304ca8114b717028e9f8d5e3ede76948e6ccf..391706f1d1abdee0ecf8a8edf7b2dc45f6cdd40d 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -930,6 +930,8 @@ int utcp_shutdown(struct utcp_connection *c, int dir) {
 int utcp_close(struct utcp_connection *c) {
        if(utcp_shutdown(c, SHUT_RDWR))
                return -1;
+       c->recv = NULL;
+       c->poll = NULL;
        c->reapable = true;
        return 0;
 }
@@ -946,6 +948,8 @@ int utcp_abort(struct utcp_connection *c) {
                return -1;
        }
 
+       c->recv = NULL;
+       c->poll = NULL;
        c->reapable = true;
 
        switch(c->state) {