From 4f9a96f6cdee4cf234bde7fdafd0be0f5b6b808e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 19 Aug 2011 08:41:53 -0600 Subject: Cancel all ccthreads first before joining them on cleanup. --- libdimension/threads.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libdimension/threads.c b/libdimension/threads.c index d4bddd3..4cefdd5 100644 --- a/libdimension/threads.c +++ b/libdimension/threads.c @@ -100,9 +100,15 @@ static void dmnsn_ccthread_cleanup(void *ptr) { dmnsn_ccthread_cleanup_payload *payload = ptr; + for (unsigned int i = 0; i < payload->nthreads; ++i) { if (payload->payloads[i].started) { pthread_cancel(payload->threads[i]); + } + } + + for (unsigned int i = 0; i < payload->nthreads; ++i) { + if (payload->payloads[i].started) { dmnsn_join_thread(payload->threads[i], NULL); } } -- cgit v1.2.3