diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-12-29 13:43:49 +0200 |
---|---|---|
committer | Tasos Katsoulas <12612986+tkatsoulas@users.noreply.github.com> | 2024-02-06 16:33:22 +0200 |
commit | f9257f72697435bc62f4481b724e3d7395571c9e (patch) | |
tree | ed6c84d7f0ab5d92dae4962b777243c9ccdb7ba5 | |
parent | 75dd941bf70eabe5f7a0ba62786ad6bf2cd3fce9 (diff) |
atomically load the metric reference count (#16687)
(cherry picked from commit caf27215d1087f3ee77b1e6376b4bba7f80ecd65)
-rw-r--r-- | database/engine/metric.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/database/engine/metric.c b/database/engine/metric.c index 735ae7ace1..2e132612e7 100644 --- a/database/engine/metric.c +++ b/database/engine/metric.c @@ -127,7 +127,7 @@ static inline time_t mrg_metric_get_first_time_s_smart(MRG *mrg __maybe_unused, static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric) { size_t partition = metric->partition; - REFCOUNT expected = metric->refcount; + REFCOUNT expected = __atomic_load_n(&metric->refcount, __ATOMIC_RELAXED); REFCOUNT refcount; do { @@ -147,7 +147,7 @@ static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric) { static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, METRIC *metric) { size_t partition = metric->partition; - REFCOUNT expected = metric->refcount; + REFCOUNT expected = __atomic_load_n(&metric->refcount, __ATOMIC_RELAXED); REFCOUNT refcount; do { |