summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-12-01 19:58:43 -0500
committerBen Gamari <ben@smart-cactus.org>2020-10-24 20:59:39 -0400
commitd584923a1e1fe92a4bb38b2cd1f0bf5a3b7802f0 (patch)
tree7fc260a012bb36ab14980ecb42654a22adc38e22
parentf08951fd0279248bd4e9536e4cf44ba658aaf710 (diff)
downloadhaskell-d584923a1e1fe92a4bb38b2cd1f0bf5a3b7802f0.tar.gz
testsuite: Fix thread leak in hs_try_putmvar00[13]
-rw-r--r--testsuite/tests/concurrent/should_run/hs_try_putmvar001_c.c1
-rw-r--r--testsuite/tests/concurrent/should_run/hs_try_putmvar003_c.c5
2 files changed, 4 insertions, 2 deletions
diff --git a/testsuite/tests/concurrent/should_run/hs_try_putmvar001_c.c b/testsuite/tests/concurrent/should_run/hs_try_putmvar001_c.c
index f214c5c4d0..583c23c2c6 100644
--- a/testsuite/tests/concurrent/should_run/hs_try_putmvar001_c.c
+++ b/testsuite/tests/concurrent/should_run/hs_try_putmvar001_c.c
@@ -28,4 +28,5 @@ void scheduleCallback(HsStablePtr mvar, HsInt cap, int *presult)
p->cap = cap;
p->presult = presult;
pthread_create(&t, NULL, callback, p);
+ pthread_detach(t);
}
diff --git a/testsuite/tests/concurrent/should_run/hs_try_putmvar003_c.c b/testsuite/tests/concurrent/should_run/hs_try_putmvar003_c.c
index d67ca43218..d3bf142455 100644
--- a/testsuite/tests/concurrent/should_run/hs_try_putmvar003_c.c
+++ b/testsuite/tests/concurrent/should_run/hs_try_putmvar003_c.c
@@ -6,6 +6,7 @@
#include "hs_try_putmvar003_stub.h"
struct callback_queue {
+ pthread_t thread;
pthread_mutex_t lock;
pthread_cond_t cond;
int use_foreign_export;
@@ -54,18 +55,18 @@ typedef void* threadfunc(void *);
struct callback_queue* mkCallbackQueue(int use_foreign_export, int n_requests)
{
struct callback_queue *q = malloc(sizeof(struct callback_queue));
- pthread_t t;
pthread_mutex_init(&q->lock, NULL);
pthread_cond_init(&q->cond, NULL);
q->pending = NULL;
q->use_foreign_export = use_foreign_export;
q->n_requests = n_requests;
- pthread_create(&t, NULL, (threadfunc*)callback, q);
+ pthread_create(&q->thread, NULL, (threadfunc*)callback, q);
return q;
}
void destroyCallbackQueue(struct callback_queue *q)
{
+ pthread_join(q->thread, NULL);
pthread_mutex_destroy(&q->lock);
pthread_cond_destroy(&q->cond);
free(q);