Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next/355/20240319/v1 #10667

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/util-profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,15 +1208,16 @@ int SCProfileRuleStart(Packet *p)
p->flags |= PKT_PROFILE;
return 1;
}
#else
#endif
if (p->flags & PKT_PROFILE) {
return 1;
}

uint64_t sample = SC_ATOMIC_ADD(samples, 1);
if (sample % rate == 0) {
if ((sample % rate) == 0) {
p->flags |= PKT_PROFILE;
return 1;
}
#endif
if (p->flags & PKT_PROFILE)
return 1;
return 0;
}

Expand Down Expand Up @@ -1450,17 +1451,20 @@ void SCProfilingInit(void)
/* see if we want to profile rules for this packet */
int SCProfileRuleStart(Packet *p)
{
/* Move first so we'll always finish even if dynamically disabled */
if (p->flags & PKT_PROFILE)
return 1;

if (!SC_ATOMIC_GET(profiling_rules_active)) {
return 0;
}

uint64_t sample = SC_ATOMIC_ADD(samples, 1);
if ((sample & rate) == 0) {
p->flags |= PKT_PROFILE;
return 1;
}

if (p->flags & PKT_PROFILE)
return 1;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util-profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void SCProfilingRuleThreatAggregate(DetectEngineThreadCtx *det_ctx);
}

#define RULE_PROFILING_END(ctx, r, m, p) \
if (profiling_rules_enabled && ((p)->flags & PKT_PROFILE)) { \
if (profiling_rules_enabled && profiling_rules_entered) { \
profile_rule_end_ = UtilCpuGetTicks(); \
SCProfilingRuleUpdateCounter( \
ctx, r->profiling_id, profile_rule_end_ - profile_rule_start_, m); \
Expand Down
Loading