Skip to content

Commit

Permalink
fix rename _stop_health_check to _enalbe_health_check
Browse files Browse the repository at this point in the history
  • Loading branch information
chenguangming committed Jun 30, 2022
1 parent 79097da commit 18d6aaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static const uint64_t AUTH_FLAG = (1ul << 32);

Socket::Socket(Forbidden)
// must be even because Address() relies on evenness of version
: _versioned_ref(0)
:_versioned_ref(0)
, _shared_part(NULL)
, _nevent(0)
, _keytable_pool(NULL)
Expand All @@ -434,7 +434,7 @@ Socket::Socket(Forbidden)
, _parsing_context(NULL)
, _correlation_id(0)
, _health_check_interval_s(-1)
, _stop_health_check(false)
, _enalbe_health_check(true)
, _ninprocess(1)
, _auth_flag_error(0)
, _auth_id(INVALID_BTHREAD_ID)
Expand Down Expand Up @@ -615,7 +615,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) {
m->reset_parsing_context(options.initial_parsing_context);
m->_correlation_id = 0;
m->_health_check_interval_s = options.health_check_interval_s;
m->_stop_health_check = false;
m->_enalbe_health_check = true;
m->_ninprocess.store(1, butil::memory_order_relaxed);
m->_auth_flag_error.store(0, butil::memory_order_relaxed);
const int rc2 = bthread_id_create(&m->_auth_id, NULL, NULL);
Expand Down Expand Up @@ -688,7 +688,7 @@ int Socket::WaitAndReset(int32_t expected_nref) {
}
}

if (_stop_health_check) {
if (!_enalbe_health_check) {
LOG(WARNING) << "stop health check thread";
return -1;
}
Expand Down Expand Up @@ -845,7 +845,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) {
// by Channel to revive never-connected socket when server side
// comes online.
if (_health_check_interval_s > 0 &&
!_stop_health_check) {
_enalbe_health_check) {
GetOrNewSharedPart()->circuit_breaker.MarkAsBroken();
StartHealthCheck(id(),
GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms());
Expand Down
7 changes: 4 additions & 3 deletions src/brpc/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ friend class policy::H2GlobalStreamCreator;
int health_check_interval() const { return _health_check_interval_s; }

// only for SocketMap
void StopHealthCheck() { _stop_health_check = true; }
void DisableHealthCheck() { _enalbe_health_check = false; }

// The unique identifier.
SocketId id() const { return _this_id; }
Expand Down Expand Up @@ -750,9 +750,10 @@ friend void DereferenceSocket(Socket*);
// Non-zero when health-checking is on.
int _health_check_interval_s;

// True when client SocketMap has removed socket.
// Default: true,
// false when client SocketMap has removed socket.
// It can be synchronized via _versioned_ref atomic variable
bool _stop_health_check;
bool _enalbe_health_check;

// +-1 bit-+---31 bit---+
// | flag | counter |
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/socket_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void SocketMap::RemoveInternal(const SocketMapKey& key,
_this_map_bvar = new bvar::PassiveStatus<std::string>(
butil::StringPiece(namebuf, len), PrintSocketMap, this);
}
s->StopHealthCheck(); // stop health check
s->DisableHealthCheck(); // disable health check
s->ReleaseAdditionalReference(); // release extra ref
SocketUniquePtr ptr(s); // Dereference
}
Expand Down

0 comments on commit 18d6aaa

Please sign in to comment.