From 261b77742e05078da4f03d4726d856fbd429d648 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 12 Nov 2019 12:44:57 +0100 Subject: [PATCH] threading: shrink and reorganize TmSlot --- src/tm-threads.c | 11 +++++++---- src/tm-threads.h | 20 ++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index 2d01fd13ad..3e4f3d6564 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -785,12 +785,15 @@ void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data) return; memset(slot, 0, sizeof(TmSlot)); SC_ATOMIC_INIT(slot->slot_data); - slot->tv = tv; slot->SlotThreadInit = tm->ThreadInit; slot->slot_initdata = data; - slot->SlotFunc = tm->Func; - slot->PktAcqLoop = tm->PktAcqLoop; - slot->Management = tm->Management; + if (tm->Func) { + slot->SlotFunc = tm->Func; + } else if (tm->PktAcqLoop) { + slot->PktAcqLoop = tm->PktAcqLoop; + } else if (tm->Management) { + slot->Management = tm->Management; + } slot->SlotThreadExitPrintStats = tm->ThreadExitPrintStats; slot->SlotThreadDeinit = tm->ThreadDeinit; /* we don't have to check for the return value "-1". We wouldn't have diff --git a/src/tm-threads.h b/src/tm-threads.h index 1fc9469c8f..57f3904e0b 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -50,13 +50,15 @@ static inline void SleepUsec(uint64_t usec) typedef TmEcode (*TmSlotFunc)(ThreadVars *, Packet *, void *, PacketQueue *); typedef struct TmSlot_ { - /* the TV holding this slot */ - ThreadVars *tv; - /* function pointers */ - TmSlotFunc SlotFunc; - - TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *); + union { + TmSlotFunc SlotFunc; + TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *); + TmEcode (*Management)(ThreadVars *, void *); + }; + /** linked list of slots, used when a pipeline has multiple slots + * in a single thread. */ + struct TmSlot_ *slot_next; TmEcode (*SlotThreadInit)(ThreadVars *, const void *, void **); void (*SlotThreadExitPrintStats)(ThreadVars *, void *); @@ -77,12 +79,6 @@ typedef struct TmSlot_ { /* slot id, only used my TmVarSlot to know what the first slot is */ int id; - /* linked list, only used when you have multiple slots(used by TmVarSlot) */ - struct TmSlot_ *slot_next; - - /* just called once, so not perf critical */ - TmEcode (*Management)(ThreadVars *, void *); - } TmSlot; extern ThreadVars *tv_root[TVT_MAX]; -- 2.47.2