Skip to content

Commit 2596dc2

Browse files
committed
profiling/rules: use atomics for rule flag
1 parent 3de687f commit 2596dc2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/util-profiling.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,13 +1421,14 @@ thread_local int profiling_rules_entered = 0;
14211421
int profiling_output_to_file = 0;
14221422
static SC_ATOMIC_DECLARE(uint64_t, samples);
14231423
static uint64_t rate = 0;
1424-
int profiling_rules_active = 0;
1424+
static SC_ATOMIC_DECLARE(bool, profiling_rules_active);
14251425

14261426
/**
14271427
* \brief Initialize profiling.
14281428
*/
14291429
void SCProfilingInit(void)
14301430
{
1431+
SC_ATOMIC_INIT(profiling_rules_active);
14311432
SC_ATOMIC_INIT(samples);
14321433
intmax_t rate_v = 0;
14331434

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

14681469
int SCProfileRuleStartCollection(void)
14691470
{
1470-
profiling_rules_active = 1;
1471+
SC_ATOMIC_SET(profiling_rules_active, true);
14711472
SCReturnInt(TM_ECODE_OK);
14721473
}
14731474

14741475
int SCProfileRuleStopCollection(void)
14751476
{
1476-
profiling_rules_active = 0;
1477+
SC_ATOMIC_SET(profiling_rules_active, false);
14771478
SCReturnInt(TM_ECODE_OK);
14781479
}
14791480

0 commit comments

Comments
 (0)