From: Guus Sliepen Date: Fri, 14 Jan 2011 15:15:03 +0000 (+0100) Subject: Cancel threads to ensure they abort blocking I/O operations. X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fac60c692a5f838bec7498f13db872774f1ea717;hp=b107b10c4ef70bdf74d6d6ac57ff5ab2698b9cb2;p=tinc Cancel threads to ensure they abort blocking I/O operations. --- diff --git a/src/net_packet.c b/src/net_packet.c index 61a9f48e..269f314c 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -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; diff --git a/src/threads.h b/src/threads.h index d2ef4a64..d55e59ed 100644 --- a/src/threads.h +++ b/src/threads.h @@ -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) {