@ -581,10 +581,11 @@ void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx *
}
}
static void SCProfilingRuleThreadMerge ( DetectEngineCtx * de_ctx , DetectEngineThreadCtx * det_ctx )
static void SCProfilingRuleThreadMerge (
DetectEngineCtx * de_ctx , DetectEngineThreadCtx * det_ctx , int reset )
{
if ( de_ctx = = NULL | | de_ctx - > profile_ctx = = NULL | | de_ctx - > profile_ctx - > data = = NULL | |
det_ctx = = NULL | | det_ctx - > rule_perf_data = = NULL )
det_ctx = = NULL | | det_ctx - > rule_perf_data = = NULL )
return ;
int i ;
@ -593,6 +594,12 @@ static void SCProfilingRuleThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThre
de_ctx - > profile_ctx - > data [ i ] . matches + = det_ctx - > rule_perf_data [ i ] . matches ;
de_ctx - > profile_ctx - > data [ i ] . ticks_match + = det_ctx - > rule_perf_data [ i ] . ticks_match ;
de_ctx - > profile_ctx - > data [ i ] . ticks_no_match + = det_ctx - > rule_perf_data [ i ] . ticks_no_match ;
if ( reset ) {
det_ctx - > rule_perf_data [ i ] . checks = 0 ;
det_ctx - > rule_perf_data [ i ] . matches = 0 ;
det_ctx - > rule_perf_data [ i ] . ticks_match = 0 ;
det_ctx - > rule_perf_data [ i ] . ticks_no_match = 0 ;
}
if ( det_ctx - > rule_perf_data [ i ] . max > de_ctx - > profile_ctx - > data [ i ] . max )
de_ctx - > profile_ctx - > data [ i ] . max = det_ctx - > rule_perf_data [ i ] . max ;
}
@ -604,7 +611,7 @@ void SCProfilingRuleThreadCleanup(DetectEngineThreadCtx *det_ctx)
return ;
pthread_mutex_lock ( & det_ctx - > de_ctx - > profile_ctx - > data_m ) ;
SCProfilingRuleThreadMerge ( det_ctx - > de_ctx , det_ctx );
SCProfilingRuleThreadMerge ( det_ctx - > de_ctx , det_ctx , 0 );
pthread_mutex_unlock ( & det_ctx - > de_ctx - > profile_ctx - > data_m ) ;
SCFree ( det_ctx - > rule_perf_data ) ;
@ -612,6 +619,16 @@ void SCProfilingRuleThreadCleanup(DetectEngineThreadCtx *det_ctx)
det_ctx - > rule_perf_data_size = 0 ;
}
void SCProfilingRuleThreatAggregate ( DetectEngineThreadCtx * det_ctx )
{
if ( det_ctx = = NULL | | det_ctx - > de_ctx = = NULL | | det_ctx - > de_ctx - > profile_ctx = = NULL )
return ;
pthread_mutex_lock ( & det_ctx - > de_ctx - > profile_ctx - > data_m ) ;
SCProfilingRuleThreadMerge ( det_ctx - > de_ctx , det_ctx , 1 ) ;
pthread_mutex_unlock ( & det_ctx - > de_ctx - > profile_ctx - > data_m ) ;
}
/**
* \ brief Register the rule profiling counters .
*
@ -651,5 +668,11 @@ SCProfilingRuleInitCounters(DetectEngineCtx *de_ctx)
SCLogPerf ( " Registered % " PRIu32 " rule profiling counters. " , count ) ;
}
int SCProfileRuleTriggerDump ( DetectEngineCtx * de_ctx )
{
SCProfilingRuleDump ( de_ctx - > profile_ctx ) ;
return TM_ECODE_OK ;
}
# endif /* PROFILING */