From 29e680bbe32d461f6f1cfa216ba157311dfcd66b Mon Sep 17 00:00:00 2001 From: chenBright Date: Wed, 17 Dec 2025 19:36:18 +0800 Subject: [PATCH] Fix a redundant BeforeAdditionalRefReleased call --- src/brpc/versioned_ref_with_id.h | 9 ++++----- test/bthread_work_stealing_queue_unittest.cpp | 9 ++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/brpc/versioned_ref_with_id.h b/src/brpc/versioned_ref_with_id.h index 20e0106d93..f77d5afa83 100644 --- a/src/brpc/versioned_ref_with_id.h +++ b/src/brpc/versioned_ref_with_id.h @@ -504,10 +504,9 @@ int VersionedRefWithId::ReleaseAdditionalReference() { do { AdditionalRefStatus expect = ADDITIONAL_REF_USING; if (_additional_ref_status.compare_exchange_strong( - expect, ADDITIONAL_REF_RECYCLED, - butil::memory_order_relaxed, - butil::memory_order_relaxed)) { - BeforeAdditionalRefReleasedWrapper(); + expect, ADDITIONAL_REF_RECYCLED, + butil::memory_order_relaxed, + butil::memory_order_relaxed)) { WRAPPER_CALL(BeforeAdditionalRefReleased, static_cast(this)); return Dereference(); } @@ -591,7 +590,7 @@ void VersionedRefWithId::Revive(int32_t at_least_nref) { int32_t nref = NRefOfVRef(vref); if (nref < at_least_nref) { - // Set the status to REF_RECYLED since no one uses this socket + // Set the status to REF_RECYCLED since no one uses this socket _additional_ref_status.store( ADDITIONAL_REF_RECYCLED, butil::memory_order_relaxed); CHECK_EQ(1, nref); diff --git a/test/bthread_work_stealing_queue_unittest.cpp b/test/bthread_work_stealing_queue_unittest.cpp index 92fbb91095..a8b110371d 100644 --- a/test/bthread_work_stealing_queue_unittest.cpp +++ b/test/bthread_work_stealing_queue_unittest.cpp @@ -21,6 +21,7 @@ #include "butil/macros.h" #include "butil/scoped_lock.h" #include "bthread/work_stealing_queue.h" +#include "bthread/processor.h" namespace { typedef size_t value_type; @@ -39,13 +40,7 @@ void* steal_thread(void* arg) { if (q->steal(&val)) { stolen->push_back(val); } else { -#if defined(ARCH_CPU_ARM_FAMILY) - asm volatile("yield\n": : :"memory"); -#elif defined(ARCH_CPU_LOONGARCH64_FAMILY) - asm volatile("nop\n": : :"memory"); -#else - asm volatile("pause\n": : :"memory"); -#endif + cpu_relax(); } } return stolen;