]> git.meshlink.io Git - meshlink/commitdiff
Reset closed connections if there is incoming data.
authorGuus Sliepen <guus@meshlink.io>
Mon, 18 May 2020 21:22:06 +0000 (23:22 +0200)
committerGuus Sliepen <guus@meshlink.io>
Mon, 18 May 2020 21:22:06 +0000 (23:22 +0200)
src/utcp.c

index d2a929bf734a598b51ff8d2dd309b08c3383516c..f81150bf7ee7ec06a1aa9d0e88c2ab5751eb743a 100644 (file)
@@ -2052,6 +2052,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;
        }