From: Guus Sliepen Date: Sun, 13 Aug 2017 19:46:24 +0000 (+0200) Subject: Call the receive callback for unclosed channels during utcp_exit(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=1d8aa0d5a55bb871ce56bca355ade80b08a7c1e5;p=utcp Call the receive callback for unclosed channels during utcp_exit(). This allows the application to clean up any resources associated with these UTCP connections. --- diff --git a/utcp.c b/utcp.c index 340b059..57b9813 100644 --- a/utcp.c +++ b/utcp.c @@ -1555,11 +1555,13 @@ void utcp_exit(struct utcp *utcp) { if(!utcp) return; for(int i = 0; i < utcp->nconnections; i++) { - if(!utcp->connections[i]->reapable) - debug("Warning, freeing unclosed connection %p\n", utcp->connections[i]); - buffer_exit(&utcp->connections[i]->rcvbuf); - buffer_exit(&utcp->connections[i]->sndbuf); - free(utcp->connections[i]); + struct utcp_connection *c = utcp->connections[i]; + if(!c->reapable) + if(c->recv) + c->recv(c, NULL, 0); + buffer_exit(&c->rcvbuf); + buffer_exit(&c->sndbuf); + free(c); } free(utcp->connections); free(utcp);