From 6841171882f1433b71a1860db8137422791677a6 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 9 Aug 2012 16:07:41 +0200 Subject: [PATCH] profiling: fix 'match' counter sometimes not incrementing. #460. --- src/detect.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/detect.c b/src/detect.c index 0f36361afa..122e4721b9 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1384,7 +1384,9 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh uint8_t sms_runflags = 0; /* function flags */ uint8_t alert_flags = 0; uint16_t alproto = ALPROTO_UNKNOWN; - int match = 0; +#ifdef PROFILING + int smatch = 0; /* signature match: 1, no match: 0 */ +#endif int fmatch = 0; uint32_t idx; uint8_t flags = 0; /* flow/state flags */ @@ -1615,6 +1617,9 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh /* inspect the sigs against the packet */ for (idx = 0; idx < det_ctx->match_array_cnt; idx++) { RULE_PROFILING_START; +#ifdef PROFILING + smatch = 0; +#endif s = det_ctx->match_array[idx]; SCLogDebug("inspecting signature id %"PRIu32"", s->id); @@ -1762,8 +1767,7 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh SCLogDebug("running match functions, sm %p", sm); for ( ; sm != NULL; sm = sm->next) { - match = sigmatch_table[sm->type].Match(th_v, det_ctx, p, s, sm); - if (match <= 0) { + if (sigmatch_table[sm->type].Match(th_v, det_ctx, p, s, sm) <= 0) { goto next; } } @@ -1815,6 +1819,9 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh /* match! */ fmatch = 1; +#ifdef PROFILING + smatch = 1; +#endif SigMatchSignaturesRunPostMatch(th_v, de_ctx, det_ctx, p, s); @@ -1824,7 +1831,7 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh next: DetectReplaceFree(det_ctx->replist); det_ctx->replist = NULL; - RULE_PROFILING_END(s, match); + RULE_PROFILING_END(s, smatch); det_ctx->flags = 0; continue;