From: Guus Sliepen Date: Wed, 27 Feb 2019 19:05:00 +0000 (+0100) Subject: Keep a copy of the old receive callback before calling reset_connection(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=b2c1a352bfa105c1d289dae31cb47b8fcc3963ff;p=utcp Keep a copy of the old receive callback before calling reset_connection(). The latter function clears the receive callback, so make a copy before calling trying to call the receive callback for the final time. --- diff --git a/utcp.c b/utcp.c index d09b9e7..9fb68ae 100644 --- a/utcp.c +++ b/utcp.c @@ -1664,11 +1664,13 @@ void utcp_abort_all_connections(struct utcp *utcp) { continue; } + utcp_recv_t old_recv = c->recv; + reset_connection(c); - if(c->recv) { + if(old_recv) { errno = 0; - c->recv(c, NULL, 0); + old_recv(c, NULL, 0); } }