Skip to content

Commit

Permalink
profiling/rules: use atomics for rule flag
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjulien committed May 12, 2023
1 parent 3de687f commit 2596dc2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/util-profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,13 +1421,14 @@ thread_local int profiling_rules_entered = 0;
int profiling_output_to_file = 0;
static SC_ATOMIC_DECLARE(uint64_t, samples);
static uint64_t rate = 0;
int profiling_rules_active = 0;
static SC_ATOMIC_DECLARE(bool, profiling_rules_active);

/**
* \brief Initialize profiling.
*/
void SCProfilingInit(void)
{
SC_ATOMIC_INIT(profiling_rules_active);
SC_ATOMIC_INIT(samples);
intmax_t rate_v = 0;

Expand All @@ -1451,7 +1452,7 @@ void SCProfilingInit(void)
/* see if we want to profile rules for this packet */
int SCProfileRuleStart(Packet *p)
{
if (profiling_rules_active != 1) {
if (!SC_ATOMIC_GET(profiling_rules_active)) {
return 0;
}
uint64_t sample = SC_ATOMIC_ADD(samples, 1);
Expand All @@ -1467,13 +1468,13 @@ int SCProfileRuleStart(Packet *p)

int SCProfileRuleStartCollection(void)
{
profiling_rules_active = 1;
SC_ATOMIC_SET(profiling_rules_active, true);
SCReturnInt(TM_ECODE_OK);
}

int SCProfileRuleStopCollection(void)
{
profiling_rules_active = 0;
SC_ATOMIC_SET(profiling_rules_active, false);
SCReturnInt(TM_ECODE_OK);
}

Expand Down

0 comments on commit 2596dc2

Please sign in to comment.