|
|
@ -1608,41 +1608,37 @@ static void TmThreadDebugValidateNoMorePackets(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* \brief Disable all threads having the specified TMs.
|
|
|
|
* \brief Disable all packet threads
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void TmThreadDisablePacketThreads(void)
|
|
|
|
void TmThreadDisablePacketThreads(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ThreadVars *tv = NULL;
|
|
|
|
|
|
|
|
struct timeval start_ts;
|
|
|
|
struct timeval start_ts;
|
|
|
|
struct timeval cur_ts;
|
|
|
|
struct timeval cur_ts;
|
|
|
|
|
|
|
|
|
|
|
|
/* first drain all packet threads of their packets */
|
|
|
|
/* first drain all packet threads of their packets */
|
|
|
|
TmThreadDrainPacketThreads();
|
|
|
|
TmThreadDrainPacketThreads();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* since all the threads possibly able to produce more packets
|
|
|
|
|
|
|
|
* are now gone or inactive, we should see no packets anywhere
|
|
|
|
|
|
|
|
* anymore. */
|
|
|
|
TmThreadDebugValidateNoMorePackets();
|
|
|
|
TmThreadDebugValidateNoMorePackets();
|
|
|
|
|
|
|
|
|
|
|
|
gettimeofday(&start_ts, NULL);
|
|
|
|
gettimeofday(&start_ts, NULL);
|
|
|
|
again:
|
|
|
|
again:
|
|
|
|
gettimeofday(&cur_ts, NULL);
|
|
|
|
gettimeofday(&cur_ts, NULL);
|
|
|
|
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
|
|
|
|
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
|
|
|
|
FatalError(SC_ERR_FATAL, "Engine unable to disable detect "
|
|
|
|
FatalError(SC_ERR_FATAL, "Engine unable to disable packet "
|
|
|
|
"thread - \"%s\". Killing engine",
|
|
|
|
"threads. Killing engine");
|
|
|
|
tv ? tv->name : "<unknown>");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* loop through the packet threads and kill them */
|
|
|
|
SCMutexLock(&tv_root_lock);
|
|
|
|
SCMutexLock(&tv_root_lock);
|
|
|
|
|
|
|
|
for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
|
|
|
|
/* all receive threads are part of packet processing threads */
|
|
|
|
|
|
|
|
tv = tv_root[TVT_PPT];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* we do have to keep in mind that TVs are arranged in the order
|
|
|
|
|
|
|
|
* right from receive to log. The moment we fail to find a
|
|
|
|
|
|
|
|
* receive TM amongst the slots in a tv, it indicates we are done
|
|
|
|
|
|
|
|
* with all receive threads */
|
|
|
|
|
|
|
|
while (tv) {
|
|
|
|
|
|
|
|
/* we found our receive TV. Send it a KILL signal. This is all
|
|
|
|
|
|
|
|
* we need to do to kill receive threads */
|
|
|
|
|
|
|
|
TmThreadsSetFlag(tv, THV_KILL);
|
|
|
|
TmThreadsSetFlag(tv, THV_KILL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* separate worker threads (autofp) will still wait at their
|
|
|
|
|
|
|
|
* input queues. So nudge them here so they will observe the
|
|
|
|
|
|
|
|
* THV_KILL flag. */
|
|
|
|
if (tv->inq != NULL) {
|
|
|
|
if (tv->inq != NULL) {
|
|
|
|
for (int i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++) {
|
|
|
|
for (int i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++) {
|
|
|
|
SCCondSignal(&trans_q[tv->inq->id].cond_q);
|
|
|
|
SCCondSignal(&trans_q[tv->inq->id].cond_q);
|
|
|
@ -1656,12 +1652,8 @@ again:
|
|
|
|
SleepMsec(1);
|
|
|
|
SleepMsec(1);
|
|
|
|
goto again;
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tv = tv->next;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCMutexUnlock(&tv_root_lock);
|
|
|
|
SCMutexUnlock(&tv_root_lock);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|