|
|
|
@ -241,7 +241,10 @@ static void PacketPoolGetReturnedPackets(PktPool *pool)
|
|
|
|
|
Packet *PacketPoolGetPacket(void)
|
|
|
|
|
{
|
|
|
|
|
PktPool *pool = GetThreadPacketPool();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(pool->initialized == 0);
|
|
|
|
|
BUG_ON(pool->destroyed == 1);
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
if (pool->head) {
|
|
|
|
|
/* Stack is not empty. */
|
|
|
|
|
Packet *p = pool->head;
|
|
|
|
@ -286,6 +289,12 @@ void PacketPoolReturnPacket(Packet *p)
|
|
|
|
|
PacketFree(p);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(pool->initialized == 0);
|
|
|
|
|
BUG_ON(pool->destroyed == 1);
|
|
|
|
|
BUG_ON(my_pool->initialized == 0);
|
|
|
|
|
BUG_ON(my_pool->destroyed == 1);
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
|
|
|
|
|
if (pool == my_pool) {
|
|
|
|
|
/* Push back onto this thread's own stack, so no locking. */
|
|
|
|
@ -338,6 +347,12 @@ void PacketPoolInitEmpty(void)
|
|
|
|
|
|
|
|
|
|
PktPool *my_pool = GetThreadPacketPool();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(my_pool->initialized);
|
|
|
|
|
my_pool->initialized = 1;
|
|
|
|
|
my_pool->destroyed = 0;
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
|
|
|
|
|
SCMutexInit(&my_pool->return_stack.mutex, NULL);
|
|
|
|
|
SCCondInit(&my_pool->return_stack.cond, NULL);
|
|
|
|
|
SC_ATOMIC_INIT(my_pool->return_stack.sync_now);
|
|
|
|
@ -353,6 +368,12 @@ void PacketPoolInit(void)
|
|
|
|
|
|
|
|
|
|
PktPool *my_pool = GetThreadPacketPool();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(my_pool->initialized);
|
|
|
|
|
my_pool->initialized = 1;
|
|
|
|
|
my_pool->destroyed = 0;
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
|
|
|
|
|
SCMutexInit(&my_pool->return_stack.mutex, NULL);
|
|
|
|
|
SCCondInit(&my_pool->return_stack.cond, NULL);
|
|
|
|
|
SC_ATOMIC_INIT(my_pool->return_stack.sync_now);
|
|
|
|
@ -371,12 +392,18 @@ void PacketPoolInit(void)
|
|
|
|
|
}
|
|
|
|
|
SCLogInfo("preallocated %"PRIiMAX" packets. Total memory %"PRIuMAX"",
|
|
|
|
|
max_pending_packets, (uintmax_t)(max_pending_packets*SIZE_OF_PACKET));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PacketPoolDestroy(void)
|
|
|
|
|
{
|
|
|
|
|
Packet *p = NULL;
|
|
|
|
|
PktPool *my_pool = GetThreadPacketPool();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(my_pool->destroyed);
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
|
|
|
|
|
if (my_pool && my_pool->pending_pool != NULL) {
|
|
|
|
|
p = my_pool->pending_head;
|
|
|
|
|
while (p) {
|
|
|
|
@ -385,7 +412,9 @@ void PacketPoolDestroy(void)
|
|
|
|
|
p = next_p;
|
|
|
|
|
my_pool->pending_count--;
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
BUG_ON(my_pool->pending_count);
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
my_pool->pending_pool = NULL;
|
|
|
|
|
my_pool->pending_head = NULL;
|
|
|
|
|
my_pool->pending_tail = NULL;
|
|
|
|
@ -396,6 +425,11 @@ void PacketPoolDestroy(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SC_ATOMIC_DESTROY(my_pool->return_stack.sync_now);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_VALIDATION
|
|
|
|
|
my_pool->initialized = 0;
|
|
|
|
|
my_pool->destroyed = 1;
|
|
|
|
|
#endif /* DEBUG_VALIDATION */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Packet *TmqhInputPacketpool(ThreadVars *tv)
|
|
|
|
|