return cnt;
}
+#define RECYCLE_MAX_QUEUE_ITEMS 25
/**
* \brief remove all flows from the hash
*
}
FBLOCK_UNLOCK(fb);
- if (local_queue.len >= 25) {
+ if (local_queue.len >= RECYCLE_MAX_QUEUE_ITEMS) {
FlowQueueAppendPrivate(&flow_recycle_q, &local_queue);
FlowWakeupFlowRecyclerThread();
}
}
- DEBUG_VALIDATE_BUG_ON(local_queue.len >= 25);
+ DEBUG_VALIDATE_BUG_ON(local_queue.len >= RECYCLE_MAX_QUEUE_ITEMS);
FlowQueueAppendPrivate(&flow_recycle_q, &local_queue);
FlowWakeupFlowRecyclerThread();
FLOWLOCK_UNLOCK(f);
}
-extern uint32_t flow_spare_pool_block_size;
-
/** \brief Thread that manages timed out flows.
*
* \param td ThreadVars cast to void ptr
/* for every full sized block, add it to the spare pool */
FlowQueuePrivateAppendFlow(&ret_queue, f);
- if (ret_queue.len == flow_spare_pool_block_size) {
+ if (ret_queue.len == FLOW_SPARE_POOL_BLOCK_SIZE) {
FlowSparePoolReturnFlows(&ret_queue);
}
}
} FlowSparePool;
static uint32_t flow_spare_pool_flow_cnt = 0;
-uint32_t flow_spare_pool_block_size = 100;
static FlowSparePool *flow_spare_pool = NULL;
static SCMutex flow_spare_pool_m = SCMUTEX_INITIALIZER;
{
DEBUG_VALIDATE_BUG_ON(p == NULL);
- for (uint32_t i = p->queue.len; i < flow_spare_pool_block_size; i++)
- {
+ for (uint32_t i = p->queue.len; i < FLOW_SPARE_POOL_BLOCK_SIZE; i++) {
Flow *f = FlowAlloc();
if (f == NULL)
return false;
}
assert(top->queue.len >= 1);
- //if (top->next != NULL)
- // assert(top->next->queue.len == flow_spare_pool_block_size);
+ // if (top->next != NULL)
+ // assert(top->next->queue.len == FLOW_SPARE_POOL_BLOCK_SIZE);
uint32_t cnt = 0;
for (FlowSparePool *p = top; p != NULL; p = p->next)
DEBUG_VALIDATE_BUG_ON(flow_spare_pool == NULL);
/* if the top is full, get a new block */
- if (flow_spare_pool->queue.len >= flow_spare_pool_block_size) {
+ if (flow_spare_pool->queue.len >= FLOW_SPARE_POOL_BLOCK_SIZE) {
FlowSparePool *p = FlowSpareGetPool();
DEBUG_VALIDATE_BUG_ON(p == NULL);
p->next = flow_spare_pool;
SCMutexLock(&flow_spare_pool_m);
flow_spare_pool_flow_cnt += fqp->len;
if (flow_spare_pool != NULL) {
- if (p->queue.len == flow_spare_pool_block_size) {
+ if (p->queue.len == FLOW_SPARE_POOL_BLOCK_SIZE) {
/* full block insert */
- if (flow_spare_pool->queue.len < flow_spare_pool_block_size) {
+ if (flow_spare_pool->queue.len < FLOW_SPARE_POOL_BLOCK_SIZE) {
p->next = flow_spare_pool->next;
flow_spare_pool->next = p;
p = NULL;
} else {
/* incomplete block insert */
- if (p->queue.len + flow_spare_pool->queue.len <= flow_spare_pool_block_size) {
+ if (p->queue.len + flow_spare_pool->queue.len <= FLOW_SPARE_POOL_BLOCK_SIZE) {
FlowQueuePrivateAppendPrivate(&flow_spare_pool->queue, &p->queue);
/* free 'p' outside of lock below */
} else {
}
/* top if full or its the only block we have */
- if (flow_spare_pool->queue.len >= flow_spare_pool_block_size || flow_spare_pool->next == NULL) {
+ if (flow_spare_pool->queue.len >= FLOW_SPARE_POOL_BLOCK_SIZE || flow_spare_pool->next == NULL) {
FlowSparePool *p = flow_spare_pool;
flow_spare_pool = p->next;
DEBUG_VALIDATE_BUG_ON(flow_spare_pool_flow_cnt < p->queue.len);
if (todo < 0) {
uint32_t to_remove = (uint32_t)(todo * -1) / 10;
while (to_remove) {
- if (to_remove < flow_spare_pool_block_size)
+ if (to_remove < FLOW_SPARE_POOL_BLOCK_SIZE)
return;
FlowSparePool *p = NULL;
} else if (todo > 0) {
FlowSparePool *head = NULL, *tail = NULL;
- uint32_t blocks = ((uint32_t)todo / flow_spare_pool_block_size) + 1;
+ uint32_t blocks = ((uint32_t)todo / FLOW_SPARE_POOL_BLOCK_SIZE) + 1;
uint32_t flow_cnt = 0;
for (uint32_t cnt = 0; cnt < blocks; cnt++) {
return cnt;
}
-extern uint32_t flow_spare_pool_block_size;
-
/** \param[in] max_work Max flows to process. 0 if unlimited. */
static void CheckWorkQueue(ThreadVars *tv, FlowWorkerThreadData *fw, FlowTimeoutCounters *counters,
FlowQueuePrivate *fq, const uint32_t max_work)
FlowClearMemory (f, f->protomap);
FLOWLOCK_UNLOCK(f);
- if (fw->fls.spare_queue.len >= (flow_spare_pool_block_size * 2)) {
+ if (fw->fls.spare_queue.len >= (FLOW_SPARE_POOL_BLOCK_SIZE * 2)) {
FlowQueuePrivatePrependFlow(&ret_queue, f);
- if (ret_queue.len == flow_spare_pool_block_size) {
+ if (ret_queue.len == FLOW_SPARE_POOL_BLOCK_SIZE) {
FlowSparePoolReturnFlows(&ret_queue);
}
} else {