summaryrefslogtreecommitdiffstats
path: root/libdimension/threads.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-09-30 12:29:08 -0400
committerTavian Barnes <tavianator@gmail.com>2010-09-30 17:19:39 -0400
commit32ccbb213b2a2d419581690d42611c375c3d22cf (patch)
tree1cdfd44c2936b0aa3d96ca54fbe30dab3d0a4c0e /libdimension/threads.c
parent312387496ec8f30b50dcb21f47e74e4eb135c63b (diff)
downloaddimension-32ccbb213b2a2d419581690d42611c375c3d22cf.tar.xz
Fix behaviour when the error handler itself calls dmnsn_error().
Diffstat (limited to 'libdimension/threads.c')
-rw-r--r--libdimension/threads.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libdimension/threads.c b/libdimension/threads.c
index 1f1acd5..2c00cc8 100644
--- a/libdimension/threads.c
+++ b/libdimension/threads.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include "dimension-impl.h"
+#include <pthread.h>
typedef struct dmnsn_thread_payload {
dmnsn_thread_fn *thread_fn;
@@ -29,7 +30,10 @@ typedef struct dmnsn_thread_payload {
static void
dmnsn_thread_cleanup(void *arg)
{
- dmnsn_progress *progress = arg;
+ dmnsn_thread_payload *payload = arg;
+ dmnsn_progress *progress = payload->progress;
+ dmnsn_free(payload);
+
dmnsn_done_progress(progress);
}
@@ -38,11 +42,11 @@ dmnsn_thread(void *arg)
{
dmnsn_thread_payload *payload = arg;
int *ret;
- pthread_cleanup_push(&dmnsn_thread_cleanup, payload->progress);
+
+ pthread_cleanup_push(&dmnsn_thread_cleanup, payload);
ret = dmnsn_malloc(sizeof(int));
*ret = (*payload->thread_fn)(payload->arg);
pthread_cleanup_pop(1);
- dmnsn_free(payload);
return ret;
}