X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Futcp.c;h=1c0890c6743b4a71b4da052bdb7ee800958b71ad;hb=da55b444c063c510f37e4f8527982eb86f01c7b3;hp=d2a929bf734a598b51ff8d2dd309b08c3383516c;hpb=f13b47a184094c6c9c22faf22c4e6b1117a1d758;p=meshlink diff --git a/src/utcp.c b/src/utcp.c index d2a929bf..1c0890c6 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -17,16 +17,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" #include #include "utcp_priv.h" @@ -423,7 +414,6 @@ static int compare(const void *va, const void *vb) { const struct utcp_connection *b = *(struct utcp_connection **)vb; assert(a && b); - assert(a->src && b->src); int c = (int)a->src - (int)b->src; @@ -2052,6 +2042,11 @@ void utcp_abort_all_connections(struct utcp *utcp) { } int utcp_close(struct utcp_connection *c) { + if(c->rcvbuf.used) { + fprintf(stderr, "UTCP channel closed with stuff in receive buffer\n"); + return reset_connection(c) ? 0 : -1; + } + if(utcp_shutdown(c, SHUT_RDWR) && errno != ENOTCONN) { return -1; }