]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packetpool: return one packet as well on sync now
authorVictor Julien <vjulien@oisf.net>
Tue, 12 Sep 2023 10:27:03 +0000 (12:27 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 1 Nov 2023 05:50:27 +0000 (06:50 +0100)
If a thread is hitting the packet pool return on a 'sync_now' return
the packet also if it is the first packet since the last flush.

Bug: #6435.

src/tmqh-packetpool.c

index e7bacf57b29ef6d702765e9602cad778076a2969..411af684ee2e04526db71276df5a76046a7f17f0 100644 (file)
@@ -172,18 +172,21 @@ void PacketPoolReturnPacket(Packet *p)
         my_pool->head = p;
     } else {
         PktPool *pending_pool = my_pool->pending_pool;
-        if (pending_pool == NULL) {
-            /* No pending packet, so store the current packet. */
-            p->next = NULL;
-            my_pool->pending_pool = pool;
-            my_pool->pending_head = p;
-            my_pool->pending_tail = p;
-            my_pool->pending_count = 1;
-        } else if (pending_pool == pool) {
-            /* Another packet for the pending pool list. */
-            p->next = my_pool->pending_head;
-            my_pool->pending_head = p;
-            my_pool->pending_count++;
+        if (pending_pool == NULL || pending_pool == pool) {
+            if (pending_pool == NULL) {
+                /* No pending packet, so store the current packet. */
+                p->next = NULL;
+                my_pool->pending_pool = pool;
+                my_pool->pending_head = p;
+                my_pool->pending_tail = p;
+                my_pool->pending_count = 1;
+            } else if (pending_pool == pool) {
+                /* Another packet for the pending pool list. */
+                p->next = my_pool->pending_head;
+                my_pool->pending_head = p;
+                my_pool->pending_count++;
+            }
+
             if (SC_ATOMIC_GET(pool->return_stack.sync_now) || my_pool->pending_count > max_pending_return_packets) {
                 /* Return the entire list of pending packets. */
                 SCMutexLock(&pool->return_stack.mutex);