Commit d4201928 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

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 fde20f7a
...@@ -275,6 +275,7 @@ smp_thread(struct sess *sp, void *priv) ...@@ -275,6 +275,7 @@ smp_thread(struct sess *sp, void *priv)
(void)sp; (void)sp;
CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC); CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC);
sc->thread = pthread_self();
/* First, load all the objects from all segments */ /* First, load all the objects from all segments */
VTAILQ_FOREACH(sg, &sc->segments, list) VTAILQ_FOREACH(sg, &sc->segments, list)
...@@ -306,6 +307,7 @@ static void ...@@ -306,6 +307,7 @@ static void
smp_open(const struct stevedore *st) smp_open(const struct stevedore *st)
{ {
struct smp_sc *sc; struct smp_sc *sc;
pthread_t pt;
ASSERT_CLI(); ASSERT_CLI();
...@@ -347,7 +349,7 @@ smp_open(const struct stevedore *st) ...@@ -347,7 +349,7 @@ smp_open(const struct stevedore *st)
smp_new_seg(sc); smp_new_seg(sc);
/* Start the worker silo worker thread, it will load the objects */ /* 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); VTAILQ_INSERT_TAIL(&silos, sc, list);
Lck_Unlock(&sc->mtx); 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