Introduce another solution to solve stream timeout shutdown issue using thread flags. No more MSSyncPts

remotes/origin/master-1.1.x
Anoop Saldanha 14 years ago committed by Victor Julien
parent aef957c6eb
commit b0a588beeb

@ -471,6 +471,10 @@ static void *SCPerfMgmtThread(void *arg)
}
}
while (!TmThreadsCheckFlag(tv_local, THV_DEINIT)) {
usleep(100);
}
TmThreadsSetFlag(tv_local, THV_CLOSED);
return NULL;
}
@ -535,11 +539,15 @@ static void *SCPerfWakeupThread(void *arg)
}
if (TmThreadsCheckFlag(tv_local, THV_KILL)) {
TmThreadsSetFlag(tv_local, THV_CLOSED);
run = 0;
}
}
while (!TmThreadsCheckFlag(tv_local, THV_DEINIT)) {
usleep(100);
}
TmThreadsSetFlag(tv_local, THV_CLOSED);
return NULL;
}

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

@ -1486,6 +1486,7 @@ void FlowForceReassembly(void)
}
TmThreadsSetFlag(tv, THV_KILL);
TmThreadsSetFlag(tv, THV_DEINIT);
/* be sure it has shut down */
while (!TmThreadsCheckFlag(tv, THV_CLOSED)) {
@ -1737,6 +1738,10 @@ void *FlowManagerThread(void *td)
}
}
while (!TmThreadsCheckFlag(th_v, THV_DEINIT)) {
usleep(100);
}
FlowHashDebugDeinit();
SCLogInfo("%" PRIu32 " new flows, %" PRIu32 " established flows were "

@ -39,6 +39,9 @@ struct TmSlot_;
#define THV_KILL 0x08 /** thread has been asked to cleanup and exit */
#define THV_FAILED 0x10 /** thread has encountered an error and failed */
#define THV_CLOSED 0x20 /** thread done, should be joinable */
/* used to indicate the thread is going through de-init. Introduced as more
* of a hack for solving stream-timeout-shutdown. Is set by the main thread. */
#define THV_DEINIT 0x40
/** Thread flags set and read by threads, to control the threads, when they
* encounter certain conditions like failure */

@ -177,9 +177,13 @@ void *TmThreadsSlot1NoIn(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -251,9 +255,13 @@ void *TmThreadsSlot1NoOut(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -320,9 +328,13 @@ void *TmThreadsSlot1NoInOut(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -424,9 +436,13 @@ void *TmThreadsSlot1(void *td)
}
} /* while (run) */
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
if (s->SlotThreadExitPrintStats != NULL) {
s->SlotThreadExitPrintStats(tv, s->slot_data);
@ -581,9 +597,13 @@ void *TmThreadsSlotPktAcqLoop(void *td) {
}
SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0);
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
for (slot = s; slot != NULL; slot = slot->slot_next) {
if (slot->SlotThreadExitPrintStats != NULL) {
@ -705,9 +725,13 @@ void *TmThreadsSlotVar(void *td)
} /* while (run) */
SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0);
while (!TmThreadsCheckFlag(tv, THV_DEINIT)) {
usleep(100);
}
/* wait for synchronization from master, if this TV has a synchronization
* point set by this name */
TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
//TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit");
s = (TmSlot *)tv->tm_slots;
@ -1376,6 +1400,7 @@ void TmThreadKillThread(ThreadVars *tv)
/* set the thread flag informing the thread that it needs to be
* terminated */
TmThreadsSetFlag(tv, THV_KILL);
TmThreadsSetFlag(tv, THV_DEINIT);
if (tv->inq != NULL) {
/* signal the queue for the number of users */
@ -1510,9 +1535,10 @@ void TmThreadKillThreads(void) {
}
TmThreadsSetFlag(tv, THV_KILL);
TmThreadsSetFlag(tv, THV_DEINIT);
SCLogDebug("told thread %s to stop", tv->name);
TmThreadsMSMasterDisableSlaveAllSyncPts(tv);
//TmThreadsMSMasterDisableSlaveAllSyncPts(tv);
if (tv->inq != NULL) {
int i;

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

Loading…
Cancel
Save