]> git.meshlink.io Git - meshlink/blobdiff - src/utcp.c
Don't use assert() to check the results of pthread_*() calls.
[meshlink] / src / utcp.c
index d2a929bf734a598b51ff8d2dd309b08c3383516c..1c0890c6743b4a71b4da052bdb7ee800958b71ad 100644 (file)
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#define _GNU_SOURCE
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <unistd.h>
+#include "system.h"
 #include <time.h>
 
 #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;
        }