]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packetpool: remove WaitForN logic as it is unused
authorVictor Julien <vjulien@oisf.net>
Tue, 12 Sep 2023 10:15:54 +0000 (12:15 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 1 Nov 2023 05:50:27 +0000 (06:50 +0100)
src/tmqh-packetpool.c
src/tmqh-packetpool.h

index 90d52bf787a43992de4c6b30493c039497393062..e7bacf57b29ef6d702765e9602cad778076a2969 100644 (file)
@@ -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
index a48fb23b5f63fc0ecd473a679fbd4d52aafb29c9..2e9672d4458c9cb3bb80556ccbecc482e01dab0e 100644 (file)
@@ -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);