Fix code that allows the engine to restart threads that have exited on failure

remotes/origin/master-1.1.x
Anoop Saldanha 14 years ago committed by Victor Julien
parent 524af82b1a
commit ff7284e7b7

@ -468,11 +468,11 @@ static void *SCPerfMgmtThread(void *arg)
SCPerfOutputCounters();
if (TmThreadsCheckFlag(tv_local, THV_KILL)) {
TmThreadsSetFlag(tv_local, THV_CLOSED);
run = 0;
}
}
TmThreadsSetFlag(tv_local, THV_CLOSED);
return NULL;
}

@ -1156,6 +1156,7 @@ void *FlowManagerThread(void *td)
SCLogInfo("prune_usecnt %"PRIu64, prune_usecnt);
#endif
TmThreadsSetFlag(th_v, THV_CLOSED);
pthread_exit((void *) 0);
}

@ -66,6 +66,8 @@ SCDQDataQueue data_queues[256];
/* memset to zeros, and mutex init! */
void GlobalInits();
extern uint8_t suricata_ctl_flags;
/* uppercase to lowercase conversion lookup table */
uint8_t g_u8_lowercasetable[256];

@ -41,7 +41,7 @@ struct TmSlot_;
#define THV_CLOSED 0x20 /** thread done, should be joinable */
/** Thread flags set and read by threads, to control the threads, when they
encounter certain conditions like failure */
* encounter certain conditions like failure */
#define THV_RESTART_THREAD 0x01 /** restart the thread */
#define THV_ENGINE_EXIT 0x02 /** shut the engine down gracefully */

@ -1467,12 +1467,17 @@ void TmThreadCheckThreadState(void)
while (tv) {
if (TmThreadsCheckFlag(tv, THV_FAILED)) {
pthread_join(tv->t, NULL);
if ( !(tv_aof & THV_ENGINE_EXIT) &&
(tv->aof & THV_RESTART_THREAD) ) {
TmThreadRestartThread(tv);
} else {
TmThreadsSetFlag(tv, THV_CLOSED);
if (tv_aof & THV_ENGINE_EXIT || tv->aof & THV_ENGINE_EXIT) {
EngineKill();
return;
} else {
/* if the engine kill-stop has been received by now, chuck
* restarting and return to kill the engine */
if (suricata_ctl_flags & SURICATA_KILL ||
suricata_ctl_flags & SURICATA_STOP) {
return;
}
TmThreadRestartThread(tv);
}
}
tv = tv->next;

Loading…
Cancel
Save