From 94c5ecb069e34008a6fc9d238c532e6ee852035c Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Thu, 8 Sep 2011 17:25:22 +0530 Subject: [PATCH] introduce inline function version of TmThreadsSlotProcessPkt macro. Retain the macro as well --- src/tm-threads.c | 26 ---------------------- src/tm-threads.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index ced89b1194..41502b64bc 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -503,32 +503,6 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, */ -#if 0 -/** - * \brief Process the rest of the functions (if any) and queue. - */ -TmEcode TmThreadsSlotProcessPkt(ThreadVars *tv, TmSlot *s, Packet *p) { - TmEcode r; - - if (likely(p != NULL)) { - if (s != NULL ) { - /* run the thread module(s) */ - r = TmThreadsSlotVarRun(tv, p, s); - if (unlikely(r == TM_ECODE_FAILED)) { - TmqhOutputPacketpool(tv, p); - TmThreadsSetFlag(tv, THV_FAILED); - return TM_ECODE_FAILED; - } - } - - /* output the packet */ - tv->tmqh_out(tv, p); - } - - return TM_ECODE_OK; -} -#endif - void *TmThreadsSlotPktAcqLoop(void *td) { ThreadVars *tv = (ThreadVars *)td; TmSlot *s = tv->tm_slots; diff --git a/src/tm-threads.h b/src/tm-threads.h index 4863843fdc..6812381e83 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -25,6 +25,7 @@ #ifndef __TM_THREADS_H__ #define __TM_THREADS_H__ +#include "tmqh-packetpool.h" #include "tm-threads-common.h" #include "tm-modules.h" @@ -83,8 +84,6 @@ void TmThreadKillThreads(void); void TmThreadAppend(ThreadVars *, int); void TmThreadRemove(ThreadVars *, int); -TmEcode TmThreadsSlotProcessPkt(ThreadVars *, TmSlot *, Packet *); - TmEcode TmThreadSetCPUAffinity(ThreadVars *, uint16_t); TmEcode TmThreadSetThreadPriority(ThreadVars *, int); TmEcode TmThreadSetCPU(ThreadVars *, uint8_t); @@ -108,6 +107,8 @@ void TmThreadsUnsetFlag(ThreadVars *, uint8_t); TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot); +#if 0 + /** * \brief Process the rest of the functions (if any) and queue. */ @@ -157,4 +158,55 @@ TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot); r; \ }) +#endif /* #if 0 */ + +/** + * \brief Process the rest of the functions (if any) and queue. + */ +static inline TmEcode TmThreadsSlotProcessPkt(ThreadVars *tv, TmSlot *s, Packet *p) +{ + TmEcode r = TM_ECODE_OK; + + if (s == NULL) { + tv->tmqh_out(tv, p); + return r; + } + + if (TmThreadsSlotVarRun(tv, p, s) == TM_ECODE_FAILED) { + TmqhOutputPacketpool(tv, p); + TmSlot *slot = s; + while (slot != NULL) { + TmqhReleasePacketsToPacketPool(&slot->slot_post_pq); + slot = slot->slot_next; + } + TmThreadsSetFlag(tv, THV_FAILED); + r = TM_ECODE_FAILED; + + } else { + tv->tmqh_out(tv, p); + /* post process pq */ + TmSlot *slot = s; + while (slot != NULL) { + while (slot->slot_post_pq.top != NULL) { + Packet *extra_p = PacketDequeue(&slot->slot_post_pq); + if (extra_p != NULL) { + if (slot->slot_next != NULL) { + r = TmThreadsSlotVarRun(tv, extra_p, slot->slot_next); + if (r == TM_ECODE_FAILED) { + TmqhReleasePacketsToPacketPool(&slot->slot_post_pq); + TmqhOutputPacketpool(tv, extra_p); + TmThreadsSetFlag(tv, THV_FAILED); + break; + } + } + tv->tmqh_out(tv, extra_p); + } + } + slot = slot->slot_next; + } + } + + return r; +} + #endif /* __TM_THREADS_H__ */