From: Victor Julien Date: Mon, 25 Nov 2019 18:45:42 +0000 (+0100) Subject: threading: add debug validation for stale packets X-Git-Tag: suricata-5.0.1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58b9a2dc2135e491307f6aeb32d007ee325ca458;p=thirdparty%2Fsuricata.git threading: add debug validation for stale packets --- diff --git a/src/tm-threads.c b/src/tm-threads.c index 08bce9f6ad..512168c062 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -1649,6 +1649,21 @@ again: return; } +static void TmThreadDebugValidateNoMorePackets(void) +{ +#ifdef DEBUG_VALIDATION + SCMutexLock(&tv_root_lock); + for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) { + if (ThreadStillHasPackets(tv)) { + SCMutexUnlock(&tv_root_lock); + TmThreadDumpThreads(); + abort(); + } + } + SCMutexUnlock(&tv_root_lock); +#endif +} + /** * \brief Disable all threads having the specified TMs. */ @@ -1660,6 +1675,7 @@ void TmThreadDisablePacketThreads(void) /* first drain all packet threads of their packets */ TmThreadDrainPacketThreads(); + TmThreadDebugValidateNoMorePackets(); gettimeofday(&start_ts, NULL); again: