chenBright commented on code in PR #3691:
URL: https://github.com/apache/brpc/pull/3691#discussion_r4426064401
##########
src/brpc/versioned_ref_with_id.h:
##########
@@ -628,18 +648,24 @@ int VersionedRefWithId<T>::Dereference() {
template<typename T>
void VersionedRefWithId<T>::Revive(int32_t at_least_nref) {
+ AdditionalRefStatus expect = ADDITIONAL_REF_RELEASED_ON_FAILURE;
+ if (!_additional_ref_status.compare_exchange_strong(
+ expect, ADDITIONAL_REF_REVIVING,
+ butil::memory_order_relaxed,
+ butil::memory_order_relaxed)) {
+ CHECK_EQ(ADDITIONAL_REF_RELEASED, expect);
Review Comment:
`Revive()` has a single production call site in `HealthCheckTask`. Health
checks for a socket are serialized, and `WaitAndReset(2)` ensures that the
additional reference has been released before revival is attempted.
Under these calling constraints, `USING` and a concurrent `REVIVING`
state are not expected. Permanent removal is the legitimate CAS failure case.
Keeping the CHECK helps detect violations of these assumptions; silently
accepting other states would hide them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]