This is an automated email from the ASF dual-hosted git repository. guangmingchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new e8c777ca Fix socket _versioned_ref can not recover && remove _hc_started flag (#3060) e8c777ca is described below commit e8c777caa844cec044ad12e8ad92b8ae5d7da81f Author: sunhao <mo...@hotmail.com> AuthorDate: Sun Aug 10 15:11:03 2025 +0800 Fix socket _versioned_ref can not recover && remove _hc_started flag (#3060) --- src/brpc/details/health_check.cpp | 3 --- src/brpc/socket.cpp | 18 +++--------------- src/brpc/socket.h | 7 ------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index dd45f1a2..cfd49104 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -183,7 +183,6 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { _first_time = false; if (ptr->WaitAndReset(2/*note*/) != 0) { LOG(INFO) << "Cancel checking " << *ptr; - ptr->AfterHCCompleted(); return false; } } @@ -210,11 +209,9 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { if (!ptr->health_check_path().empty()) { HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } - ptr->AfterHCCompleted(); return false; } else if (hc == ESTOP) { LOG(INFO) << "Cancel checking " << *ptr; - ptr->AfterHCCompleted(); return false; } else { RPC_VLOG << "Fail to check " << *ptr diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index dc56281c..d0f60c7e 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -467,7 +467,6 @@ Socket::Socket(Forbidden f) , _correlation_id(0) , _health_check_interval_s(-1) , _is_hc_related_ref_held(false) - , _hc_started(false) , _ninprocess(1) , _auth_flag_error(0) , _auth_id(INVALID_BTHREAD_ID) @@ -744,7 +743,6 @@ int Socket::OnCreated(const SocketOptions& options) { _health_check_interval_s = options.health_check_interval_s; _hc_option = options.hc_option; _is_hc_related_ref_held = false; - _hc_started.store(false, butil::memory_order_relaxed); _ninprocess.store(1, butil::memory_order_relaxed); _auth_flag_error.store(0, butil::memory_order_relaxed); const int rc2 = bthread_id_create(&_auth_id, NULL, NULL); @@ -915,19 +913,9 @@ void Socket::OnFailed(int error_code, const std::string& error_text) { // by Channel to revive never-connected socket when server side // comes online. if (HCEnabled()) { - bool expect = false; - if (_hc_started.compare_exchange_strong(expect, - true, - butil::memory_order_relaxed, - butil::memory_order_relaxed)) { - GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); - StartHealthCheck(id(), - GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms()); - } else { - // No need to run 2 health checking at the same time. - RPC_VLOG << "There is already a health checking running " - "for SocketId=" << id(); - } + GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); + StartHealthCheck(id(), + GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms()); } // Wake up all threads waiting on EPOLLOUT when closing fd _epollout_butex->fetch_add(1, butil::memory_order_relaxed); diff --git a/src/brpc/socket.h b/src/brpc/socket.h index e94d612a..03ad43f8 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -430,9 +430,6 @@ public: // reference which is held on created. void ReleaseHCRelatedReference(); - // After health checking is complete, set _hc_started to false. - void AfterHCCompleted() { _hc_started.store(false, butil::memory_order_relaxed); } - // `user' parameter passed to Create(). SocketUser* user() const { return _user; } @@ -886,10 +883,6 @@ private: // synchronized via _versioned_ref atomic variable. bool _is_hc_related_ref_held; - // Default: false. - // true, if health checking is started. - butil::atomic<bool> _hc_started; - // +-1 bit-+---31 bit---+ // | flag | counter | // +-------+------------+ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org