]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
The isc_refcount_decrement must use memory_order_release and isc_refcount_destroy...
authorOndřej Surý <ondrej@sury.org>
Fri, 27 Jul 2018 12:17:09 +0000 (14:17 +0200)
committerOndřej Surý <ondrej@sury.org>
Wed, 8 Aug 2018 07:49:06 +0000 (09:49 +0200)
lib/isc/include/isc/refcount.h

index 69f3441dfa3542c8a5b08bedde38d08ad94b4468..709b51e2c551666d0c6fd9bc43f7f45c09b06a1a 100644 (file)
@@ -111,8 +111,13 @@ typedef struct isc_refcount {
 
 #define isc_refcount_current(rp)                                       \
        ((unsigned int)(atomic_load_explicit(&(rp)->refs,               \
-                                            memory_order_relaxed)))
-#define isc_refcount_destroy(rp) ISC_REQUIRE(isc_refcount_current(rp) == 0)
+                                            memory_order_acquire)))
+
+#define isc_refcount_destroy(rp)                               \
+       do {                                                    \
+               atomic_thread_fence(memory_order_acquire);      \
+               ISC_REQUIRE(isc_refcount_current(rp) == 0);     \
+       } while (0)
 
 #define isc_refcount_increment0(rp, tp)                                \
        do {                                                    \
@@ -140,7 +145,7 @@ typedef struct isc_refcount {
                unsigned int *_tmp = (unsigned int *)(tp);      \
                isc_int32_t prev;                               \
                prev = atomic_fetch_sub_explicit                \
-                       (&(rp)->refs, 1, memory_order_relaxed); \
+                       (&(rp)->refs, 1, memory_order_release); \
                ISC_REQUIRE(prev > 0);                          \
                if (_tmp != NULL)                               \
                        *_tmp = prev - 1;                       \