return;
#endif
ThreadVars *tv = NULL;
- int cnt = 0;
/* wake up threads */
uint32_t u;
SCCtrlCondSignal(&flow_manager_ctrl_cond);
SCMutexLock(&tv_root_lock);
-
/* flow manager thread(s) is/are a part of mgmt threads */
tv = tv_root[TVT_MGMT];
-
while (tv != NULL)
{
if (strncasecmp(tv->name, thread_name_flow_mgr,
strlen(thread_name_flow_mgr)) == 0)
{
TmThreadsSetFlag(tv, THV_KILL);
- cnt++;
+ }
+ tv = tv->next;
+ }
+ SCMutexUnlock(&tv_root_lock);
- /* value in seconds */
-#define THREAD_KILL_MAX_WAIT_TIME 60
- /* value in microseconds */
-#define WAIT_TIME 100
+ double total_wait_time = 0;
+ /* value in seconds */
+ #define THREAD_KILL_MAX_WAIT_TIME 60
+ /* value in microseconds */
+ #define WAIT_TIME 100
+
+again:
+ SCMutexLock(&tv_root_lock);
+
+ tv = tv_root[TVT_MGMT];
+ while (tv != NULL)
+ {
+ if (strncasecmp(tv->name, thread_name_flow_mgr,
+ strlen(thread_name_flow_mgr)) == 0)
+ {
+ if (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
+ SCMutexUnlock(&tv_root_lock);
- double total_wait_time = 0;
- while (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
usleep(WAIT_TIME);
total_wait_time += WAIT_TIME / 1000000.0;
if (total_wait_time > THREAD_KILL_MAX_WAIT_TIME) {
"Killing engine", tv->name);
exit(EXIT_FAILURE);
}
+ goto again;
}
}
tv = tv->next;
SCCtrlCondSignal(&flow_recycler_ctrl_cond);
SCMutexLock(&tv_root_lock);
-
/* flow recycler thread(s) is/are a part of mgmt threads */
tv = tv_root[TVT_MGMT];
-
while (tv != NULL)
{
if (strncasecmp(tv->name, thread_name_flow_rec,
{
TmThreadsSetFlag(tv, THV_KILL);
cnt++;
+ }
+ tv = tv->next;
+ }
+ SCMutexUnlock(&tv_root_lock);
- /* value in seconds */
+ double total_wait_time = 0;
+ /* value in seconds */
#define THREAD_KILL_MAX_WAIT_TIME 60
- /* value in microseconds */
+ /* value in microseconds */
#define WAIT_TIME 100
- double total_wait_time = 0;
- while (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
- usleep(WAIT_TIME);
- total_wait_time += WAIT_TIME / 1000000.0;
+again:
+ SCMutexLock(&tv_root_lock);
+ tv = tv_root[TVT_MGMT];
+ while (tv != NULL)
+ {
+ if (strncasecmp(tv->name, thread_name_flow_rec,
+ strlen(thread_name_flow_rec)) == 0)
+ {
+ if (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
if (total_wait_time > THREAD_KILL_MAX_WAIT_TIME) {
SCLogError(SC_ERR_FATAL, "Engine unable to "
"disable detect thread - \"%s\". "
"Killing engine", tv->name);
exit(EXIT_FAILURE);
}
+ SCMutexUnlock(&tv_root_lock);
+ usleep(WAIT_TIME);
+ total_wait_time += WAIT_TIME / 1000000.0;
+ goto again;
}
}
tv = tv->next;
/* wait for it to enter the 'flow loop' stage */
while (!TmThreadsCheckFlag(tv, THV_FLOW_LOOP)) {
+ SCMutexUnlock(&tv_root_lock);
+
usleep(WAIT_TIME);
total_wait_time += WAIT_TIME / 1000000.0;
if (total_wait_time > THREAD_KILL_MAX_WAIT_TIME) {
"Killing engine", tv->name);
exit(EXIT_FAILURE);
}
+ goto again;
}
}
}
while (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
+ SCMutexUnlock(&tv_root_lock);
+
usleep(WAIT_TIME);
total_wait_time += WAIT_TIME / 1000000.0;
if (total_wait_time > THREAD_KILL_MAX_WAIT_TIME) {
"Killing engine", tv->name);
exit(EXIT_FAILURE);
}
+ goto again;
}
tv = tv->next;
int i = 0;
uint16_t mgt_num = 0;
uint16_t ppt_num = 0;
-
+again:
SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv != NULL) {
- char started = FALSE;
- 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_INIT_DONE))) {
+ SCMutexUnlock(&tv_root_lock);
+ /* sleep a little to give the thread some
+ * time to finish initialization */
+ usleep(100);
+ goto again;
+ }
- if (TmThreadsCheckFlag(tv, THV_FAILED)) {
- SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
- "initialize.", tv->name);
- return TM_ECODE_FAILED;
- }
- if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
- SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" closed on "
- "initialization.", tv->name);
- return TM_ECODE_FAILED;
- }
+ if (TmThreadsCheckFlag(tv, THV_FAILED)) {
+ SCMutexUnlock(&tv_root_lock);
+ SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
+ "initialize.", tv->name);
+ return TM_ECODE_FAILED;
+ }
+ if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
+ SCMutexUnlock(&tv_root_lock);
+ SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" closed on "
+ "initialization.", tv->name);
+ return TM_ECODE_FAILED;
}
- if (i == TVT_MGMT) mgt_num++;
- else if (i == TVT_PPT) ppt_num++;
+ if (i == TVT_MGMT)
+ mgt_num++;
+ else if (i == TVT_PPT)
+ ppt_num++;
tv = tv->next;
}
ThreadVars *tv = NULL;
int cnt = 0;
+again:
SCCtrlCondSignal(&unix_manager_ctrl_cond);
-
SCMutexLock(&tv_root_lock);
/* flow manager thread(s) is/are a part of mgmt threads */
TmThreadsSetFlag(tv, THV_DEINIT);
/* be sure it has shut down */
- while (!TmThreadsCheckFlag(tv, THV_CLOSED)) {
+ if(!(TmThreadsCheckFlag(tv, THV_CLOSED))) {
+ SCMutexUnlock(&tv_root_lock);
usleep(100);
+ goto again;
}
cnt++;
}
{
ThreadVars *tv = NULL;
+again:
SCMutexLock(&tv_root_lock);
/* unix manager thread(s) is/are a part of command threads */
TmThreadsSetFlag(tv, THV_KILL);
TmThreadsSetFlag(tv, THV_DEINIT);
/* Be sure it has shut down */
- while (!TmThreadsCheckFlag(tv, THV_CLOSED)) {
+ if (!TmThreadsCheckFlag(tv, THV_CLOSED)) {
+ SCMutexUnlock(&tv_root_lock);
usleep(100);
+ goto again;
}
}
tv = tv->next;