From bfb6aac495968713d74c6fc6f3f611769de0cd8f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 9 Oct 2010 17:01:02 +0200 Subject: [PATCH] Sleep after checking for a thread flag in TmThreadWaitOnThreadInit now that the check is so much cheaper. --- src/tm-threads.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index b3231ec0a4..b2c2e5c979 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -75,7 +75,7 @@ uint8_t tv_aof = THV_RESTART_THREAD; * \retval 0 flag is not set */ int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag) { - return ((SC_ATOMIC_GET(tv->flags) & flag)? 1 : 0); + return (SC_ATOMIC_GET(tv->flags) & flag) ? 1 : 0; } /** @@ -1385,6 +1385,10 @@ TmEcode TmThreadWaitOnThreadInit(void) while (started == FALSE) { if (TmThreadsCheckFlag(tv, THV_INIT_DONE)) { started = TRUE; + } else { + /* sleep a little to give the thread some + * time to finish initialization */ + usleep(100); } if (TmThreadsCheckFlag(tv, THV_FAILED)) {