From: Victor Julien Date: Tue, 12 Sep 2023 10:15:54 +0000 (+0200) Subject: packetpool: remove WaitForN logic as it is unused X-Git-Tag: suricata-7.0.3~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ae37b06f1f40e569e529f8c2965116c1da6f9f8;p=thirdparty%2Fsuricata.git packetpool: remove WaitForN logic as it is unused --- diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index 90d52bf787..e7bacf57b2 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -81,62 +81,6 @@ void PacketPoolWait(void) cc_barrier(); } -/** \brief Wait until we have the requested amount of packets in the pool - * - * In some cases waiting for packets is undesirable. Especially when - * a wait would happen under a lock of some kind, other parts of the - * engine could have to wait. - * - * This function only returns when at least N packets are in our pool. - * - * If counting in our pool's main stack didn't give us the number we - * are seeking, we check if the return stack is filled and add those - * to our main stack. Then we retry. - * - * \param n number of packets needed - */ -void PacketPoolWaitForN(int n) -{ - PktPool *my_pool = GetThreadPacketPool(); - - while (1) { - PacketPoolWait(); - - /* count packets in our stack */ - int i = 0; - Packet *p, *pp; - pp = p = my_pool->head; - while (p != NULL) { - if (++i == n) - return; - - pp = p; - p = p->next; - } - - /* check return stack, return to our pool and retry counting */ - if (my_pool->return_stack.head != NULL) { - SCMutexLock(&my_pool->return_stack.mutex); - /* Move all the packets from the locked return stack to the local stack. */ - if (pp) { - pp->next = my_pool->return_stack.head; - } else { - my_pool->head = my_pool->return_stack.head; - } - my_pool->return_stack.head = NULL; - SC_ATOMIC_RESET(my_pool->return_stack.sync_now); - SCMutexUnlock(&my_pool->return_stack.mutex); - - /* or signal that we need packets and wait */ - } else { - SCMutexLock(&my_pool->return_stack.mutex); - SC_ATOMIC_ADD(my_pool->return_stack.sync_now, 1); - SCCondWait(&my_pool->return_stack.cond, &my_pool->return_stack.mutex); - SCMutexUnlock(&my_pool->return_stack.mutex); - } - } -} - /** \brief a initialized packet * * \warning Use *only* at init, not at packet runtime diff --git a/src/tmqh-packetpool.h b/src/tmqh-packetpool.h index a48fb23b5f..2e9672d445 100644 --- a/src/tmqh-packetpool.h +++ b/src/tmqh-packetpool.h @@ -72,7 +72,6 @@ void TmqhReleasePacketsToPacketPool(PacketQueue *); void TmqhPacketpoolRegister(void); Packet *PacketPoolGetPacket(void); void PacketPoolWait(void); -void PacketPoolWaitForN(int n); void PacketPoolReturnPacket(Packet *p); void PacketPoolInit(void); void PacketPoolInitEmpty(void);