summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-08-19 08:41:53 -0600
committerTavian Barnes <tavianator@gmail.com>2011-08-19 08:41:53 -0600
commit4f9a96f6cdee4cf234bde7fdafd0be0f5b6b808e (patch)
tree78bc047797262d2447086f31efe3996ac1ae096a
parentc0284b69fe0ee82d1f604a1b6f0511b4f129b919 (diff)
downloaddimension-4f9a96f6cdee4cf234bde7fdafd0be0f5b6b808e.tar.xz
Cancel all ccthreads first before joining them on cleanup.
-rw-r--r--libdimension/threads.c6
1 files changed, 6 insertions, 0 deletions
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);
}
}