]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threading: add debug validation for stale packets
authorVictor Julien <victor@inliniac.net>
Mon, 25 Nov 2019 18:45:42 +0000 (19:45 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 25 Nov 2019 18:46:08 +0000 (19:46 +0100)
src/tm-threads.c

index 08bce9f6ad6f7f8f230512f2d5f929298e226aec..512168c062b69f46138ec95ccdf6813f54e12065 100644 (file)
@@ -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: