mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Use release memory ordering when incrementing reference counter
As the relaxed memory ordering doesn't ensure any memory
synchronization, it is possible that the increment will succeed even
in the case when it should not - there is a race between
atomic_fetch_sub(..., acq_rel) and atomic_fetch_add(..., relaxed).
Only the result is consistent, but the previous value for both calls
could be same when both calls are executed at the same time.
(cherry picked from commit 88227ea665)
This commit is contained in:
parent
aa078bdd37
commit
5701bf9dab
1 changed files with 2 additions and 2 deletions
|
|
@ -70,7 +70,7 @@ typedef atomic_uint_fast32_t isc_refcount_t;
|
|||
#define isc_refcount_increment0(target) \
|
||||
({ \
|
||||
uint_fast32_t __v; \
|
||||
__v = atomic_fetch_add_relaxed(target, 1); \
|
||||
__v = atomic_fetch_add_release(target, 1); \
|
||||
INSIST(__v < UINT32_MAX); \
|
||||
__v; \
|
||||
})
|
||||
|
|
@ -83,7 +83,7 @@ typedef atomic_uint_fast32_t isc_refcount_t;
|
|||
#define isc_refcount_increment(target) \
|
||||
({ \
|
||||
uint_fast32_t __v; \
|
||||
__v = atomic_fetch_add_relaxed(target, 1); \
|
||||
__v = atomic_fetch_add_release(target, 1); \
|
||||
INSIST(__v > 0 && __v < UINT32_MAX); \
|
||||
__v; \
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue