Commit 2d927b12 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Don't protect the barriers list with a lock

A command like `barrier r1` would fail while holding the lock because of
the invalid name, but the reset of the test case would then deadlock. It
leads to a timeout like we see sometimes on VTEST so getting rid of them
may just require to review when `vtc_fatal` is called while locking.

In this very case we can only create barriers in the top thread so the
lock is useless.
parent 4c9b097f
...@@ -828,7 +828,6 @@ exec_file(const char *fn, const char *script, const char *tmpdir, ...@@ -828,7 +828,6 @@ exec_file(const char *fn, const char *script, const char *tmpdir,
AN(vltop); AN(vltop);
init_macro(); init_macro();
init_barrier();
init_server(); init_server();
/* Move into our tmpdir */ /* Move into our tmpdir */
......
...@@ -67,7 +67,6 @@ struct barrier { ...@@ -67,7 +67,6 @@ struct barrier {
volatile unsigned need_join; volatile unsigned need_join;
}; };
static pthread_mutex_t barrier_mtx;
static VTAILQ_HEAD(, barrier) barriers = VTAILQ_HEAD_INITIALIZER(barriers); static VTAILQ_HEAD(, barrier) barriers = VTAILQ_HEAD_INITIALIZER(barriers);
static struct barrier * static struct barrier *
...@@ -412,7 +411,6 @@ cmd_barrier(CMD_ARGS) ...@@ -412,7 +411,6 @@ cmd_barrier(CMD_ARGS)
(void)cmd; (void)cmd;
if (av == NULL) { if (av == NULL) {
AZ(pthread_mutex_lock(&barrier_mtx));
/* Reset and free */ /* Reset and free */
VTAILQ_FOREACH_SAFE(b, &barriers, list, b2) { VTAILQ_FOREACH_SAFE(b, &barriers, list, b2) {
r = pthread_mutex_trylock(&b->mtx); r = pthread_mutex_trylock(&b->mtx);
...@@ -432,23 +430,20 @@ cmd_barrier(CMD_ARGS) ...@@ -432,23 +430,20 @@ cmd_barrier(CMD_ARGS)
} }
AZ(pthread_mutex_unlock(&b->mtx)); AZ(pthread_mutex_unlock(&b->mtx));
} }
AZ(pthread_mutex_unlock(&barrier_mtx));
return; return;
} }
AZ(strcmp(av[0], "barrier")); AZ(strcmp(av[0], "barrier"));
av++; av++;
AZ(pthread_mutex_lock(&barrier_mtx));
VTAILQ_FOREACH(b, &barriers, list) VTAILQ_FOREACH(b, &barriers, list)
if (!strcmp(b->name, av[0])) if (!strcmp(b->name, av[0]))
break; break;
if (b == NULL) if (b == NULL)
b = barrier_new(av[0], vl); b = barrier_new(av[0], vl);
av++; av++;
AZ(pthread_mutex_lock(&b->mtx));
AZ(pthread_mutex_unlock(&barrier_mtx));
AZ(pthread_mutex_lock(&b->mtx));
for (; *av != NULL; av++) { for (; *av != NULL; av++) {
if (!strcmp(*av, "cond")) { if (!strcmp(*av, "cond")) {
av++; av++;
...@@ -474,10 +469,3 @@ cmd_barrier(CMD_ARGS) ...@@ -474,10 +469,3 @@ cmd_barrier(CMD_ARGS)
} }
AZ(pthread_mutex_unlock(&b->mtx)); AZ(pthread_mutex_unlock(&b->mtx));
} }
void
init_barrier(void)
{
AZ(pthread_mutex_init(&barrier_mtx, NULL));
}
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