Cancel threads to ensure they abort blocking I/O operations.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 14 Jan 2011 15:15:03 +0000 (16:15 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 14 Jan 2011 15:15:03 +0000 (16:15 +0100)
src/net_packet.c
src/threads.h

index 61a9f48..269f314 100644 (file)
@@ -589,11 +589,8 @@ void handle_incoming_vpn_data(void *arg) {
                len = recvfrom(l->udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
 
                if(len <= 0 || len > MAXSIZE) {
-                       if(!sockwouldblock(sockerrno)) {
-                               logger(LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno));
-                               return;
-                       }
-                       continue;
+                       logger(LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno));
+                       return;
                }
 
                pkt.len = len;
index d2ef4a6..d55e59e 100644 (file)
@@ -32,6 +32,7 @@ static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg)
        return !pthread_create(tid, NULL, (void *(*)(void *))func, arg);
 }
 static inline void thread_destroy(thread_t *tid) {
+       pthread_cancel(*tid);
        pthread_join(*tid, NULL);
 }
 static inline void mutex_create(mutex_t *mutex) {