From: Victor Julien Date: Tue, 12 Sep 2023 10:27:03 +0000 (+0200) Subject: packetpool: return one packet as well on sync now X-Git-Tag: suricata-7.0.3~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=087ca49e397a4643ff1e8762e4a02277737caef1;p=thirdparty%2Fsuricata.git packetpool: return one packet as well on sync now 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. --- diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index e7bacf57b2..411af684ee 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -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);