From fac60c692a5f838bec7498f13db872774f1ea717 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 14 Jan 2011 16:15:03 +0100 Subject: [PATCH] Cancel threads to ensure they abort blocking I/O operations. --- src/net_packet.c | 7 ++----- src/threads.h | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/net_packet.c b/src/net_packet.c index 61a9f48..269f314 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 d2ef4a6..d55e59e 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) { -- 2.25.1