[health checking] connected subchannel may be null on READY notification

pull/37781/head
Mark D. Roth 2 months ago
parent c6c461bc0e
commit 7eaf22ecd5
  1. 8
      src/core/load_balancing/health_check_client.cc

@ -403,13 +403,17 @@ void HealthProducer::OnConnectivityStateChange(grpc_connectivity_state state,
<< ": subchannel state update: state=" << ConnectivityStateName(state) << ": subchannel state update: state=" << ConnectivityStateName(state)
<< " status=" << status; << " status=" << status;
MutexLock lock(&mu_); MutexLock lock(&mu_);
state_ = state;
status_ = status;
if (state == GRPC_CHANNEL_READY) { if (state == GRPC_CHANNEL_READY) {
connected_subchannel_ = subchannel_->connected_subchannel(); connected_subchannel_ = subchannel_->connected_subchannel();
// If the subchannel became disconnected again before we got this
// notification, then just ignore the READY notification. We should
// get another notification shortly indicating a different state.
if (connected_subchannel_ == nullptr) return;
} else { } else {
connected_subchannel_.reset(); connected_subchannel_.reset();
} }
state_ = state;
status_ = status;
for (const auto& p : health_checkers_) { for (const auto& p : health_checkers_) {
p.second->OnConnectivityStateChangeLocked(state, status); p.second->OnConnectivityStateChangeLocked(state, status);
} }

Loading…
Cancel
Save