mirror of
https://github.com/OISF/suricata.git
synced 2026-10-12 02:07:10 +00:00
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.
This commit is contained in:
committed by
Victor Julien
parent
bdac028fc7
commit
35e711d00a
+6
-6
@@ -2324,7 +2324,7 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
|
||||
uint32_t i = 0;
|
||||
|
||||
/* 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 */
|
||||
if (no_of_detect_tvs == 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 */
|
||||
SCMutexLock(&tv_root_lock);
|
||||
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;
|
||||
}
|
||||
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
|
||||
TmModule *tm = TmModuleGetById(s->tm_id);
|
||||
if (!(tm->flags & TM_FLAG_DETECT_TM)) {
|
||||
if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2378,12 +2378,12 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
|
||||
/* atomically replace the det_ctx data */
|
||||
i = 0;
|
||||
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;
|
||||
}
|
||||
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
|
||||
TmModule *tm = TmModuleGetById(s->tm_id);
|
||||
if (!(tm->flags & TM_FLAG_DETECT_TM)) {
|
||||
if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
|
||||
continue;
|
||||
}
|
||||
SCLogDebug("swapping new det_ctx - %p with older one - %p",
|
||||
@@ -2432,7 +2432,7 @@ retry:
|
||||
* THV_DEINIT flag */
|
||||
if (i != no_of_detect_tvs) { // not all threads we swapped
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -819,5 +819,5 @@ void TmModuleFlowWorkerRegister (void)
|
||||
tmm_modules[TMM_FLOWWORKER].ThreadBusy = FlowWorkerIsBusy;
|
||||
tmm_modules[TMM_FLOWWORKER].ThreadDeinit = FlowWorkerThreadDeinit;
|
||||
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;
|
||||
}
|
||||
|
||||
+3
-3
@@ -43,7 +43,7 @@ static void WorkerFlushLogs(void)
|
||||
SCEnter();
|
||||
|
||||
/* 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 */
|
||||
if (no_of_detect_tvs == 0) {
|
||||
return;
|
||||
@@ -61,12 +61,12 @@ static void WorkerFlushLogs(void)
|
||||
SCMutexLock(&tv_root_lock);
|
||||
/* get reference to tv's and setup fw_threads array */
|
||||
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;
|
||||
}
|
||||
for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
|
||||
TmModule *tm = TmModuleGetById(s->tm_id);
|
||||
if (!(tm->flags & TM_FLAG_DETECT_TM)) {
|
||||
if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2292,7 +2292,7 @@ void PostRunDeinit(const int runmode, struct timeval *start_time)
|
||||
TmThreadDisableReceiveThreads();
|
||||
/* tell relevant packet threads to enter flow timeout loop */
|
||||
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 */
|
||||
FlowWorkToDoCleanup();
|
||||
/* gracefully shut down all packet threads */
|
||||
|
||||
+3
-5
@@ -31,16 +31,14 @@
|
||||
/* thread flags */
|
||||
#define TM_FLAG_RECEIVE_TM 0x01
|
||||
#define TM_FLAG_DECODE_TM 0x02
|
||||
#define TM_FLAG_STREAM_TM 0x04
|
||||
#define TM_FLAG_DETECT_TM 0x08
|
||||
#define TM_FLAG_FLOWWORKER_TM 0x04
|
||||
#define TM_FLAG_VERDICT_TM 0x08
|
||||
#define TM_FLAG_MANAGEMENT_TM 0x10
|
||||
#define TM_FLAG_COMMAND_TM 0x20
|
||||
#define TM_FLAG_VERDICT_TM 0x40
|
||||
|
||||
/* all packet modules combined */
|
||||
#define TM_FLAG_PACKET_ALL \
|
||||
(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM | \
|
||||
TM_FLAG_VERDICT_TM)
|
||||
(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_FLOWWORKER_TM | TM_FLAG_VERDICT_TM)
|
||||
|
||||
typedef TmEcode (*ThreadInitFunc)(ThreadVars *, const void *, void **);
|
||||
typedef TmEcode (*ThreadDeinitFunc)(ThreadVars *, void *);
|
||||
|
||||
@@ -465,7 +465,7 @@ void PacketPoolPostRunmodes(void)
|
||||
"must be at least %d",
|
||||
RESERVED_PACKETS);
|
||||
}
|
||||
uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM);
|
||||
uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
|
||||
if (threads == 0)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user