fb->idx = idx;
fb->next = NULL;
GenericVarAppend(&f->flowvar, (GenericVar *)fb);
-
- //printf("FlowBitAdd: adding flowbit with idx %" PRIu32 "\n", idx);
-#ifdef FLOWBITS_STATS
- SCMutexLock(&flowbits_mutex);
- flowbits_added++;
- flowbits_memuse += sizeof(FlowBit);
- if (flowbits_memuse > flowbits_memuse_max)
- flowbits_memuse_max = flowbits_memuse;
- SCMutexUnlock(&flowbits_mutex);
-#endif /* FLOWBITS_STATS */
}
}
GenericVarRemove(&f->flowvar, (GenericVar *)fb);
FlowBitFree(fb);
-
- //printf("FlowBitRemove: remove flowbit with idx %" PRIu32 "\n", idx);
-#ifdef FLOWBITS_STATS
- SCMutexLock(&flowbits_mutex);
- flowbits_removed++;
- if (flowbits_memuse >= sizeof(FlowBit))
- flowbits_memuse -= sizeof(FlowBit);
- else {
- printf("ERROR: flowbits memory usage going below 0!\n");
- flowbits_memuse = 0;
- }
- SCMutexUnlock(&flowbits_mutex);
-#endif /* FLOWBITS_STATS */
}
void FlowBitSetNoLock(Flow *f, uint16_t idx)
return;
SCFree(fb);
-
-#ifdef FLOWBITS_STATS
- SCMutexLock(&flowbits_mutex);
- flowbits_removed++;
- if (flowbits_memuse >= sizeof(FlowBit))
- flowbits_memuse -= sizeof(FlowBit);
- else {
- printf("ERROR: flowbits memory usage going below 0!\n");
- flowbits_memuse = 0;
- }
- SCMutexUnlock(&flowbits_mutex);
-#endif /* FLOWBITS_STATS */
}
/** flow memuse counter (atomic), for enforcing memcap limit */
SC_ATOMIC_DECLARE(long long unsigned int, flow_memuse);
-//#define FLOWBITS_STATS
-#ifdef FLOWBITS_STATS
-uint64_t flowbits_memuse;
-uint64_t flowbits_memuse_max;
-uint32_t flowbits_added;
-uint32_t flowbits_removed;
-SCMutex flowbits_mutex;
-#endif /* FLOWBITS_STATS */
-
#endif /* __FLOW_PRIVATE_H__ */
* \warning Not thread safe */
static void FlowPrintStats (void)
{
-#ifdef FLOWBITS_STATS
- SCLogInfo("flowbits added: %" PRIu32 ", removed: %" PRIu32 ", max memory usage: %" PRIu32 "",
- flowbits_added, flowbits_removed, flowbits_memuse_max);
-#endif /* FLOWBITS_STATS */
return;
}