threads: clean up module flags

Remove unused TM_FLAG_STREAM_TM.

Rename TM_FLAG_DETECT_TM to TM_FLAG_FLOWWORKER_TM as it was mostly used
to check if a thread is a flow worker. TM_FLAG_DETECT_TM was always set
for a flow worker, even when there was no detection in use.
pull/13419/head
Victor Julien 2 months ago committed by Victor Julien
parent bdac028fc7
commit 35e711d00a

@ -2324,7 +2324,7 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
uint32_t i = 0; uint32_t i = 0;
/* count detect threads in use */ /* count detect threads in use */
uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM); uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
/* can be zero in unix socket mode */ /* can be zero in unix socket mode */
if (no_of_detect_tvs == 0) { if (no_of_detect_tvs == 0) {
return 0; return 0;
@ -2343,12 +2343,12 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
/* get reference to tv's and setup new_det_ctx array */ /* get reference to tv's and setup new_det_ctx array */
SCMutexLock(&tv_root_lock); SCMutexLock(&tv_root_lock);
for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) { for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) { if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
continue; continue;
} }
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) { for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
TmModule *tm = TmModuleGetById(s->tm_id); TmModule *tm = TmModuleGetById(s->tm_id);
if (!(tm->flags & TM_FLAG_DETECT_TM)) { if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
continue; continue;
} }
@ -2378,12 +2378,12 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
/* atomically replace the det_ctx data */ /* atomically replace the det_ctx data */
i = 0; i = 0;
for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) { for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) { if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
continue; continue;
} }
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) { for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
TmModule *tm = TmModuleGetById(s->tm_id); TmModule *tm = TmModuleGetById(s->tm_id);
if (!(tm->flags & TM_FLAG_DETECT_TM)) { if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
continue; continue;
} }
SCLogDebug("swapping new det_ctx - %p with older one - %p", SCLogDebug("swapping new det_ctx - %p with older one - %p",
@ -2432,7 +2432,7 @@ retry:
* THV_DEINIT flag */ * THV_DEINIT flag */
if (i != no_of_detect_tvs) { // not all threads we swapped if (i != no_of_detect_tvs) { // not all threads we swapped
for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) { for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) { if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
continue; continue;
} }

@ -819,5 +819,5 @@ void TmModuleFlowWorkerRegister (void)
tmm_modules[TMM_FLOWWORKER].ThreadBusy = FlowWorkerIsBusy; tmm_modules[TMM_FLOWWORKER].ThreadBusy = FlowWorkerIsBusy;
tmm_modules[TMM_FLOWWORKER].ThreadDeinit = FlowWorkerThreadDeinit; tmm_modules[TMM_FLOWWORKER].ThreadDeinit = FlowWorkerThreadDeinit;
tmm_modules[TMM_FLOWWORKER].cap_flags = 0; tmm_modules[TMM_FLOWWORKER].cap_flags = 0;
tmm_modules[TMM_FLOWWORKER].flags = TM_FLAG_STREAM_TM|TM_FLAG_DETECT_TM; tmm_modules[TMM_FLOWWORKER].flags = TM_FLAG_FLOWWORKER_TM;
} }

@ -43,7 +43,7 @@ static void WorkerFlushLogs(void)
SCEnter(); SCEnter();
/* count detect threads in use */ /* count detect threads in use */
uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM); uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
/* can be zero in unix socket mode */ /* can be zero in unix socket mode */
if (no_of_detect_tvs == 0) { if (no_of_detect_tvs == 0) {
return; return;
@ -61,12 +61,12 @@ static void WorkerFlushLogs(void)
SCMutexLock(&tv_root_lock); SCMutexLock(&tv_root_lock);
/* get reference to tv's and setup fw_threads array */ /* get reference to tv's and setup fw_threads array */
for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) { for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) { if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
continue; continue;
} }
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) { for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
TmModule *tm = TmModuleGetById(s->tm_id); TmModule *tm = TmModuleGetById(s->tm_id);
if (!(tm->flags & TM_FLAG_DETECT_TM)) { if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
continue; continue;
} }

@ -2292,7 +2292,7 @@ void PostRunDeinit(const int runmode, struct timeval *start_time)
TmThreadDisableReceiveThreads(); TmThreadDisableReceiveThreads();
/* tell relevant packet threads to enter flow timeout loop */ /* tell relevant packet threads to enter flow timeout loop */
TmThreadDisablePacketThreads( TmThreadDisablePacketThreads(
THV_REQ_FLOW_LOOP, THV_FLOW_LOOP, (TM_FLAG_RECEIVE_TM | TM_FLAG_DETECT_TM)); THV_REQ_FLOW_LOOP, THV_FLOW_LOOP, (TM_FLAG_RECEIVE_TM | TM_FLAG_FLOWWORKER_TM));
/* run cleanup on the flow hash */ /* run cleanup on the flow hash */
FlowWorkToDoCleanup(); FlowWorkToDoCleanup();
/* gracefully shut down all packet threads */ /* gracefully shut down all packet threads */

@ -31,16 +31,14 @@
/* thread flags */ /* thread flags */
#define TM_FLAG_RECEIVE_TM 0x01 #define TM_FLAG_RECEIVE_TM 0x01
#define TM_FLAG_DECODE_TM 0x02 #define TM_FLAG_DECODE_TM 0x02
#define TM_FLAG_STREAM_TM 0x04 #define TM_FLAG_FLOWWORKER_TM 0x04
#define TM_FLAG_DETECT_TM 0x08 #define TM_FLAG_VERDICT_TM 0x08
#define TM_FLAG_MANAGEMENT_TM 0x10 #define TM_FLAG_MANAGEMENT_TM 0x10
#define TM_FLAG_COMMAND_TM 0x20 #define TM_FLAG_COMMAND_TM 0x20
#define TM_FLAG_VERDICT_TM 0x40
/* all packet modules combined */ /* all packet modules combined */
#define TM_FLAG_PACKET_ALL \ #define TM_FLAG_PACKET_ALL \
(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM | \ (TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_FLOWWORKER_TM | TM_FLAG_VERDICT_TM)
TM_FLAG_VERDICT_TM)
typedef TmEcode (*ThreadInitFunc)(ThreadVars *, const void *, void **); typedef TmEcode (*ThreadInitFunc)(ThreadVars *, const void *, void **);
typedef TmEcode (*ThreadDeinitFunc)(ThreadVars *, void *); typedef TmEcode (*ThreadDeinitFunc)(ThreadVars *, void *);

@ -465,7 +465,7 @@ void PacketPoolPostRunmodes(void)
"must be at least %d", "must be at least %d",
RESERVED_PACKETS); RESERVED_PACKETS);
} }
uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM); uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
if (threads == 0) if (threads == 0)
return; return;

Loading…
Cancel
Save