packetpool: remove WaitForN logic as it is unused

pull/9727/head
Victor Julien 2 years ago committed by Victor Julien
parent 0dda7f535c
commit 6ae37b06f1

@ -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

@ -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);

Loading…
Cancel
Save