]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tm-thread: run thread init function sequentially.
authorEric Leblond <eric@regit.org>
Thu, 9 Aug 2012 14:24:18 +0000 (16:24 +0200)
committerEric Leblond <eric@regit.org>
Tue, 21 Aug 2012 15:41:25 +0000 (17:41 +0200)
On some setup you want to run each thread init function sequentially.
For example, if I use flow_cpu load balancing on AF_PACKET, my target
is to have CPU 0 (first socket in the group) to be link with the
thread 0 in detect cpu set (first thread to be initialised). A good
way to achieve this is to run only one thread init function at a time
to avoid any possible race condition.

src/tm-threads.c

index 196d7dac0d3eb56c2cde34ac467ae491c9073661..92dbcd92f8daef9a8859939fca4b69772a5e1273 100644 (file)
@@ -1710,6 +1710,8 @@ TmEcode TmThreadSpawn(ThreadVars *tv)
         return TM_ECODE_FAILED;
     }
 
+    TmThreadWaitForFlag(tv, THV_INIT_DONE);
+
     TmThreadAppend(tv, tv->type);
 
     return TM_ECODE_OK;