Commit cfcfc6a2 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Fix sporadic timeouts if we got cancelled

If we receive a cancellation during pthread_cond_(timed)wait() we will
own the mutex on the way out. Avoid locking it twice, otherwise we
will deadlock.
parent a4e07fc5
......@@ -408,6 +408,7 @@ void
cmd_barrier(CMD_ARGS)
{
struct barrier *b, *b2;
int r;
(void)priv;
(void)cmd;
......@@ -416,7 +417,8 @@ cmd_barrier(CMD_ARGS)
AZ(pthread_mutex_lock(&barrier_mtx));
/* Reset and free */
VTAILQ_FOREACH_SAFE(b, &barriers, list, b2) {
AZ(pthread_mutex_lock(&b->mtx));
r = pthread_mutex_trylock(&b->mtx);
assert(r == 0 || r == EBUSY);
switch (b->type) {
case BARRIER_COND:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment