From 1d8aa0d5a55bb871ce56bca355ade80b08a7c1e5 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 13 Aug 2017 21:46:24 +0200 Subject: [PATCH] Call the receive callback for unclosed channels during utcp_exit(). This allows the application to clean up any resources associated with these UTCP connections. --- utcp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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); -- 2.39.2