X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Futcp.c;h=ca91bee26ef6d21c0f0f57dd743c27c0f9b14f8b;hp=fa45e9c625b4b4e1d28c07ea49d881dad40e2107;hb=2bd86439e6cee8742a01bb715461be62f6d33ac8;hpb=932ce5bb0058ad5e757bd83476e297404f1bcb8b diff --git a/src/utcp.c b/src/utcp.c index fa45e9c6..ca91bee2 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -2077,9 +2077,6 @@ static bool reset_connection(struct utcp_connection *c) { buffer_clear(&c->sndbuf); buffer_clear(&c->rcvbuf); - c->recv = NULL; - c->poll = NULL; - switch(c->state) { case CLOSED: return true; @@ -2127,8 +2124,8 @@ static void set_reapable(struct utcp_connection *c) { c->reapable = true; } -// Closes all the opened connections -void utcp_abort_all_connections(struct utcp *utcp) { +// Resets all connections, but does not invalidate connection handles +void utcp_reset_all_connections(struct utcp *utcp) { if(!utcp) { errno = EINVAL; return; @@ -2141,19 +2138,16 @@ void utcp_abort_all_connections(struct utcp *utcp) { continue; } - utcp_recv_t old_recv = c->recv; - utcp_poll_t old_poll = c->poll; + reset_connection(c); - utcp_abort(c); - - if(old_recv) { + if(c->recv) { errno = 0; - old_recv(c, NULL, 0); + c->recv(c, NULL, 0); } - if(old_poll && !c->reapable) { + if(c->poll && !c->reapable) { errno = 0; - old_poll(c, 0); + c->poll(c, 0); } }