aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2018-09-26 21:13:52 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2018-09-26 21:13:52 +0200
commitb41822a1c7031c417287e646a8bb23c1b4a1ac4d (patch)
tree100f3fbbd7c664a0fb0be95b7e6db6d9809382ea
parent6c54897035ec11d9434e1c49e82cf937bd41ae90 (diff)
downloadlibrb-b41822a1c7031c417287e646a8bb23c1b4a1ac4d.tar.gz
librb-b41822a1c7031c417287e646a8bb23c1b4a1ac4d.tar.bz2
librb-b41822a1c7031c417287e646a8bb23c1b4a1ac4d.zip
fix: race condition in mt_fail() check
-rw-r--r--tests.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests.c b/tests.c
index 1a7e152..df1e30f 100644
--- a/tests.c
+++ b/tests.c
@@ -249,11 +249,14 @@ static void *multi_consumer(void *arg)
* force exit received
*/
- mt_fail(errno == ECANCELED);
- return NULL;
+ int *e = malloc(sizeof(int));
+ *e = errno;
+ return e;
}
}
}
+
+ return NULL;
}
static void *multi_pipe_consumer(void *arg)
@@ -516,7 +519,10 @@ static void multi_file_consumer_producer(void)
{
for (i = 0; i != t_num_consumers; ++i)
{
- pthread_join(cons[i], NULL);
+ int *r;
+ pthread_join(cons[i], (void **)&r);
+ mt_fail(*r == ECANCELED);
+ free(r);
}
pthread_join(*prod, NULL);
pthread_join(pipet, NULL);