SCLogDebug("stats_thread_data %p", &stats_thread_data);
TmThreadsSetFlag(tv_local, THV_INIT_DONE | THV_RUNNING);
- while (1) {
- TmThreadsWaitForUnpause(tv_local);
-
+ bool run = TmThreadsWaitForUnpause(tv_local);
+ while (run) {
struct timeval cur_timev;
gettimeofday(&cur_timev, NULL);
struct timespec cond_time = FROM_TIMEVAL(cur_timev);
}
TmThreadsSetFlag(tv_local, THV_INIT_DONE | THV_RUNNING);
+ bool run = TmThreadsWaitForUnpause(tv_local);
- while (1) {
- TmThreadsWaitForUnpause(tv_local);
-
+ while (run) {
struct timeval cur_timev;
gettimeofday(&cur_timev, NULL);
struct timespec cond_time = FROM_TIMEVAL(cur_timev);
TmThreadsSetFlag(th_v, THV_INIT_DONE | THV_RUNNING);
SCLogDebug("loader thread started");
- while (1)
- {
- TmThreadsWaitForUnpause(th_v);
-
+ bool run = TmThreadsWaitForUnpause(th_v);
+ while (run) {
/* see if we have tasks */
DetectLoaderControl *loader = &loaders[ftd->instance];
return TM_ECODE_OK;
TmThreadsSetFlag(th_v, THV_RUNNING);
+ bool run = TmThreadsWaitForUnpause(th_v);
- while (1) {
- TmThreadsWaitForUnpause(th_v);
+ while (run) {
SCLogDebug("Dumping the table");
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &curtime);
StatsSetUI64(th_v, ftd->cnt.flow_mgr_rows_sec, rows_sec);
TmThreadsSetFlag(th_v, THV_RUNNING);
+ bool run = TmThreadsWaitForUnpause(th_v);
- while (1)
- {
- TmThreadsWaitForUnpause(th_v);
-
+ while (run) {
bool emerg = ((SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY) != 0);
/* Get the time */
FlowQueuePrivate ret_queue = { NULL, NULL, 0 };
TmThreadsSetFlag(th_v, THV_RUNNING);
+ bool run = TmThreadsWaitForUnpause(th_v);
- while (1)
- {
- TmThreadsWaitForUnpause(th_v);
+ while (run) {
SC_ATOMIC_ADD(flowrec_busy,1);
FlowQueuePrivate list = FlowQueueExtractPrivate(&flow_recycle_q);
{
ThreadVars *tv = (ThreadVars *)td;
TmSlot *s = tv->tm_slots;
- char run = 1;
TmEcode r = TM_ECODE_OK;
TmSlot *slot = NULL;
StatsSetupPrivate(tv);
TmThreadsSetFlag(tv, THV_INIT_DONE);
+ bool run = TmThreadsWaitForUnpause(tv);
- while(run) {
- TmThreadsWaitForUnpause(tv);
-
+ while (run) {
r = s->PktAcqLoop(tv, SC_ATOMIC_GET(s->slot_data), s);
if (r == TM_ECODE_FAILED) {
TmThreadsSetFlag(tv, THV_FAILED);
- run = 0;
+ run = false;
}
if (TmThreadsCheckFlag(tv, THV_KILL_PKTACQ) || suricata_ctl_flags) {
- run = 0;
+ run = false;
}
if (r == TM_ECODE_DONE) {
- run = 0;
+ run = false;
}
}
StatsSyncCounters(tv);
/**
* Also returns if the kill flag is set.
*/
-void TmThreadsWaitForUnpause(ThreadVars *tv)
+bool TmThreadsWaitForUnpause(ThreadVars *tv)
{
if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
TmThreadsSetFlag(tv, THV_PAUSED);
SleepUsec(100);
if (TmThreadsCheckFlag(tv, THV_KILL))
- break;
+ return false;
}
TmThreadsUnsetFlag(tv, THV_PAUSED);
}
+
+ return true;
}
static void *TmThreadsSlotVar(void *td)
ThreadVars *tv = (ThreadVars *)td;
TmSlot *s = (TmSlot *)tv->tm_slots;
Packet *p = NULL;
- char run = 1;
TmEcode r = TM_ECODE_OK;
CaptureStatsSetup(tv);
// enter infinite loops. They use this as the core loop. As a result, at this
// point the worker threads can be considered both initialized and running.
TmThreadsSetFlag(tv, THV_INIT_DONE | THV_RUNNING);
+ bool run = TmThreadsWaitForUnpause(tv);
s = (TmSlot *)tv->tm_slots;
while (run) {
- TmThreadsWaitForUnpause(tv);
-
/* input a packet */
p = tv->tmqh_in(tv);
}
if (TmThreadsCheckFlag(tv, THV_KILL)) {
- run = 0;
+ run = false;
}
} /* while (run) */
StatsSyncCounters(tv);
*
* Check if a thread should wait to be unpaused and wait if so, or
* until the thread kill flag is set.
+ *
+ * \returns true if the thread was unpaused, false if killed.
*/
-void TmThreadsWaitForUnpause(ThreadVars *tv);
+bool TmThreadsWaitForUnpause(ThreadVars *tv);
#endif /* SURICATA_TM_THREADS_H */