/* Do remember. We need to have packet acquire disabled by now */
/** ----- Part 1 ----- **/
- /* First we need to kill the flow manager thread */
- FlowKillFlowManagerThread();
-
- /** ----- Part 2 ----- **/
/* Check if all threads are idle. We need this so that we have all
* packets freeds. As a consequence, no flows are in use */
SCMutexUnlock(&tv_root_lock);
- /** ----- Part 3 ----- **/
+ /** ----- Part 2 ----- **/
/* Carry out flow reassembly for unattended flows */
FlowForceReassemblyForHash();
tmm_modules[TMM_STREAMTCP].ThreadDeinit = StreamTcpThreadDeinit;
tmm_modules[TMM_STREAMTCP].RegisterTests = StreamTcpRegisterTests;
tmm_modules[TMM_STREAMTCP].cap_flags = 0;
+ tmm_modules[TMM_STREAMTCP].flags = TM_FLAG_STREAM_TM;
}
void StreamTcpIncrMemuse(uint64_t size) {
SCCudaPBKillBatchingPackets();
#endif
+ /* First we need to kill the flow manager thread */
+ FlowKillFlowManagerThread();
+
/* Disable packet acquire thread first */
TmThreadDisableReceiveThreads();
if (rule_reload == 1) {
/* Disable detect threads first. This is required by live rule swap */
- TmThreadDisableDetectThreads();
+ TmThreadDisableUptoDetectThreads();
/* wait if live rule swap is in progress */
if (UtilSignalIsHandler(SIGUSR2, SignalHandlerSigusr2Idle)) {
/* thread flags */
#define TM_FLAG_RECEIVE_TM 0x01
#define TM_FLAG_DECODE_TM 0x02
-#define TM_FLAG_DETECT_TM 0x04
+#define TM_FLAG_STREAM_TM 0x04
+#define TM_FLAG_DETECT_TM 0x08
typedef struct TmModule_ {
char *name;
}
/**
- * \brief Disable all detect threads.
+ * \brief Disable all threads <= detect.
*/
-void TmThreadDisableDetectThreads(void)
+void TmThreadDisableUptoDetectThreads(void)
{
/* value in seconds */
#define THREAD_KILL_MAX_WAIT_TIME 60
* receive TM amongst the slots in a tv, it indicates we are done
* with all receive threads */
while (tv) {
+ int disable = 0;
/* obtain the slots for this TV */
TmSlot *slots = tv->tm_slots;
while (slots != NULL) {
TmModule *tm = TmModuleGetById(slots->tm_id);
- if (!(tm->flags & TM_FLAG_DETECT_TM)) {
- slots = slots->slot_next;
- continue;
+ if (tm->flags & (TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM |
+ TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM)) {
+ disable = 1;
+ break;
+ }
+
+ slots = slots->slot_next;
+ continue;
+ }
+
+ if (disable) {
+ if (tv->inq != NULL) {
+ /* we wait till we dry out all the inq packets, before we
+ * kill this thread. Do note that you should have disabled
+ * packet acquire by now using TmThreadDisableReceiveThreads()*/
+ if (!(strlen(tv->inq->name) == strlen("packetpool") &&
+ strcasecmp(tv->inq->name, "packetpool") == 0)) {
+ PacketQueue *q = &trans_q[tv->inq->id];
+ while (q->len != 0) {
+ usleep(1000);
+ }
+ }
}
/* we found our receive TV. Send it a KILL signal. This is all
exit(EXIT_FAILURE);
}
}
-
- break;
}
tv = tv->next;
ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *);
void TmThreadDisableReceiveThreads(void);
-void TmThreadDisableDetectThreads(void);
+void TmThreadDisableUptoDetectThreads(void);
TmSlot *TmThreadGetFirstTmSlotForPartialPattern(const char *);
/**