From fd6faac196ab4e2eac3ab60b66c6a1fb6492f38a Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Thu, 8 Sep 2011 16:36:06 +0530 Subject: [PATCH] update TmThreadsSlotProcessPkt with better error handling + post pq processing --- src/tm-threads.h | 59 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/src/tm-threads.h b/src/tm-threads.h index 06526e7714..4863843fdc 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -111,19 +111,50 @@ TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot); /** * \brief Process the rest of the functions (if any) and queue. */ -#define TmThreadsSlotProcessPkt(tv, s, p) ({ \ - TmEcode r = TM_ECODE_OK; \ - \ - if ((s) != NULL && \ - TmThreadsSlotVarRun((tv), (p), (s)) == TM_ECODE_FAILED) { \ - TmqhOutputPacketpool((tv), (p)); \ - TmThreadsSetFlag((tv), THV_FAILED); \ - r = TM_ECODE_FAILED; \ - } else { \ - tv->tmqh_out(tv, p); \ - } \ - \ - r; \ -}) +#define TmThreadsSlotProcessPkt(tv, s, p) \ + ({ \ + TmEcode r = TM_ECODE_OK; \ + \ + if ((s) == NULL) { \ + tv->tmqh_out((tv), (p)); \ + goto TmThreadsSlotProcessPkt_End; \ + } \ + \ + 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; \ + } \ + } \ + \ + TmThreadsSlotProcessPkt_End: \ + r; \ + }) #endif /* __TM_THREADS_H__ */