Introduce a new wrapper macro that wait loops till the flag(s) in question have been set

remotes/origin/master-1.1.x
Anoop Saldanha 14 years ago committed by Victor Julien
parent a7acf9ea8f
commit 6c95526423

@ -471,9 +471,7 @@ static void *SCPerfMgmtThread(void *arg)
}
}
while (!TmThreadsCheckFlag(tv_local, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv_local, THV_DEINIT);
TmThreadsSetFlag(tv_local, THV_CLOSED);
return NULL;
@ -543,9 +541,7 @@ static void *SCPerfWakeupThread(void *arg)
}
}
while (!TmThreadsCheckFlag(tv_local, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv_local, THV_DEINIT);
TmThreadsSetFlag(tv_local, THV_CLOSED);
return NULL;

@ -372,9 +372,7 @@ void *SCCudaPBTmThreadsSlot1(void *td)
}
}
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);

@ -1738,9 +1738,7 @@ void *FlowManagerThread(void *td)
}
}
while (!TmThreadsCheckFlag(th_v, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(th_v, THV_DEINIT);
FlowHashDebugDeinit();

@ -177,9 +177,7 @@ void *TmThreadsSlot1NoIn(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -251,9 +249,7 @@ void *TmThreadsSlot1NoOut(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -320,9 +316,7 @@ void *TmThreadsSlot1NoInOut(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -424,9 +418,7 @@ void *TmThreadsSlot1(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -581,9 +573,7 @@ void *TmThreadsSlotPktAcqLoop(void *td) {
}
SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0);
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
for (slot = s; slot != NULL; slot = slot->slot_next) {
if (slot->SlotThreadExitPrintStats != NULL) {
@ -705,9 +695,7 @@ void *TmThreadsSlotVar(void *td)
} /* while (run) */
SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0);
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
s = (TmSlot *)tv->tm_slots;
@ -1696,6 +1684,21 @@ void TmThreadTestThreadUnPaused(ThreadVars *tv)
return;
}
/**
* \brief Waits till the specified flag(s) is(are) set. We don't bother if
* the kill flag has been set or not on the thread.
*
* \param tv Pointer to the TV instance.
*/
void TmThreadWaitForFlag(ThreadVars *tv, uint8_t flags)
{
while (!TmThreadsCheckFlag(tv, flags)) {
usleep(100);
}
return;
}
/**
* \brief Unpauses a thread
*

@ -111,6 +111,7 @@ ThreadVars *TmThreadsGetCallingThread(void);
int TmThreadsCheckFlag(ThreadVars *, uint8_t);
void TmThreadsSetFlag(ThreadVars *, uint8_t);
void TmThreadsUnsetFlag(ThreadVars *, uint8_t);
void TmThreadWaitForFlag(ThreadVars *, uint8_t);
TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot);

@ -2269,9 +2269,7 @@ void *CudaMpmB2gThreadsSlot1(void *td)
}
}
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
TmThreadWaitForFlag(tv, THV_DEINIT);
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);

Loading…
Cancel
Save