|
|
|
@ -485,16 +485,26 @@ static void ThresholdCacheThreadFree(void *ptr)
|
|
|
|
|
|
|
|
|
|
|
|
static void ThresholdCacheInit(void)
|
|
|
|
static void ThresholdCacheInit(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
|
|
|
|
/* many tests don't manage the thread storage correctly, so skip the cache in unittests */
|
|
|
|
|
|
|
|
if (!(RunmodeIsUnittests())) {
|
|
|
|
|
|
|
|
#endif
|
|
|
|
/* Register thread storage. */
|
|
|
|
/* Register thread storage. */
|
|
|
|
thread_storage_id = ThreadStorageRegister(
|
|
|
|
thread_storage_id = ThreadStorageRegister(
|
|
|
|
"threshold_cache", sizeof(void *), NULL, ThresholdCacheThreadFree);
|
|
|
|
"threshold_cache", sizeof(void *), NULL, ThresholdCacheThreadFree);
|
|
|
|
if (thread_storage_id.id < 0) {
|
|
|
|
if (thread_storage_id.id < 0) {
|
|
|
|
FatalError("Failed to register threshold_cache thread storage");
|
|
|
|
FatalError("Failed to register threshold_cache thread storage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ThresholdCacheThreadInit(DetectEngineThreadCtx *det_ctx)
|
|
|
|
int ThresholdCacheThreadInit(DetectEngineThreadCtx *det_ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (thread_storage_id.id < 0)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
struct ThresholdCacheThreadCtx *tctx = SCCalloc(1, sizeof(*tctx));
|
|
|
|
struct ThresholdCacheThreadCtx *tctx = SCCalloc(1, sizeof(*tctx));
|
|
|
|
if (tctx == NULL)
|
|
|
|
if (tctx == NULL)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
|