diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-05 16:29:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-05 16:31:00 +0000 |
commit | 89b68730a8a23e3393f0fe9623ac6ec4480021a1 (patch) | |
tree | 2fdf1b5447ffd8bdd61e702ca183e814afdcb4fc /libnetdata/string/string.c | |
parent | Adding upstream version 1.37.0. (diff) | |
download | netdata-89b68730a8a23e3393f0fe9623ac6ec4480021a1.tar.xz netdata-89b68730a8a23e3393f0fe9623ac6ec4480021a1.zip |
Adding upstream version 1.37.1.upstream/1.37.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/string/string.c')
-rw-r--r-- | libnetdata/string/string.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libnetdata/string/string.c b/libnetdata/string/string.c index a3f74b4ef..d2db8aab4 100644 --- a/libnetdata/string/string.c +++ b/libnetdata/string/string.c @@ -71,11 +71,12 @@ void string_statistics(size_t *inserts, size_t *deletes, size_t *searches, size_ static inline bool string_entry_check_and_acquire(STRING *se) { REFCOUNT expected, desired, count = 0; + + expected = __atomic_load_n(&se->refcount, __ATOMIC_SEQ_CST); + do { count++; - expected = __atomic_load_n(&se->refcount, __ATOMIC_SEQ_CST); - if(expected <= 0) { // We cannot use this. // The reference counter reached value zero, @@ -85,8 +86,8 @@ static inline bool string_entry_check_and_acquire(STRING *se) { } desired = expected + 1; - } - while(!__atomic_compare_exchange_n(&se->refcount, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)); + + } while(!__atomic_compare_exchange_n(&se->refcount, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)); string_internal_stats_add(spins, count - 1); |