Commit 4711b4b3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix a race condition, the child thread could get to the first

assert before the parent carried out the assignment of the thread
id to the variable.

Detected by:	OSX
parent 86619add
......@@ -275,6 +275,7 @@ smp_thread(struct worker *wrk, void *priv)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC);
sc->thread = pthread_self();
/* First, load all the objects from all segments */
VTAILQ_FOREACH(sg, &sc->segments, list)
......@@ -305,6 +306,7 @@ static void
smp_open(const struct stevedore *st)
{
struct smp_sc *sc;
pthread_t pt;
ASSERT_CLI();
......@@ -346,7 +348,7 @@ smp_open(const struct stevedore *st)
smp_new_seg(sc);
/* Start the worker silo worker thread, it will load the objects */
WRK_BgThread(&sc->thread, "persistence", smp_thread, sc);
WRK_BgThread(&pt, "persistence", smp_thread, sc);
VTAILQ_INSERT_TAIL(&silos, sc, list);
Lck_Unlock(&sc->mtx);
......
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