From: Guus Sliepen Date: Tue, 2 Dec 2014 16:14:13 +0000 (+0100) Subject: Disable callbacks when closing a connection. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=b4e6d4bac314221a8bdb522daef24b606f143cee;p=utcp Disable callbacks when closing a connection. 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. --- diff --git a/utcp.c b/utcp.c index a79304c..391706f 100644 --- 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) {