diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-05 16:29:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-05 16:31:29 +0000 |
commit | 2d852004321781e79bb7f59bf61603d66000daae (patch) | |
tree | 0ecddb3a16d1eb813fd4a3f7f507417028d6a5bc /libnetdata/string | |
parent | Releasing debian version 1.37.0-1. (diff) | |
download | netdata-2d852004321781e79bb7f59bf61603d66000daae.tar.xz netdata-2d852004321781e79bb7f59bf61603d66000daae.zip |
Merging upstream version 1.37.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/string')
-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); |