|
|
@ -878,24 +878,19 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { |
|
|
|
"chand=%p: destroying subchannel wrapper %p for subchannel %p", |
|
|
|
"chand=%p: destroying subchannel wrapper %p for subchannel %p", |
|
|
|
chand_, this, subchannel_); |
|
|
|
chand_, this, subchannel_); |
|
|
|
} |
|
|
|
} |
|
|
|
auto *subchannel_wrapper = this; |
|
|
|
chand_->subchannel_wrappers_.erase(this); |
|
|
|
auto *subchannel = subchannel_; |
|
|
|
auto* subchannel_node = subchannel_->channelz_node(); |
|
|
|
auto *chand = chand_; |
|
|
|
if (subchannel_node != nullptr) { |
|
|
|
chand_->work_serializer()->Run([chand, subchannel, subchannel_wrapper]() { |
|
|
|
auto it = chand_->subchannel_refcount_map_.find(subchannel_); |
|
|
|
chand->subchannel_wrappers_.erase(subchannel_wrapper); |
|
|
|
GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); |
|
|
|
auto* subchannel_node = subchannel->channelz_node(); |
|
|
|
--it->second; |
|
|
|
if (subchannel_node != nullptr) { |
|
|
|
if (it->second == 0) { |
|
|
|
auto it = chand->subchannel_refcount_map_.find(subchannel); |
|
|
|
chand_->channelz_node_->RemoveChildSubchannel(subchannel_node->uuid()); |
|
|
|
GPR_ASSERT(it != chand->subchannel_refcount_map_.end()); |
|
|
|
chand_->subchannel_refcount_map_.erase(it); |
|
|
|
--it->second; |
|
|
|
|
|
|
|
if (it->second == 0) { |
|
|
|
|
|
|
|
chand->channelz_node_->RemoveChildSubchannel(subchannel_node->uuid()); |
|
|
|
|
|
|
|
chand->subchannel_refcount_map_.erase(it); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
GRPC_SUBCHANNEL_UNREF(subchannel, "unref from LB"); |
|
|
|
} |
|
|
|
GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "SubchannelWrapper"); |
|
|
|
GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); |
|
|
|
}, DEBUG_LOCATION); |
|
|
|
GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
grpc_connectivity_state CheckConnectivityState() override { |
|
|
|
grpc_connectivity_state CheckConnectivityState() override { |
|
|
@ -1016,7 +1011,12 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { |
|
|
|
parent_(std::move(parent)), |
|
|
|
parent_(std::move(parent)), |
|
|
|
last_seen_state_(initial_state) {} |
|
|
|
last_seen_state_(initial_state) {} |
|
|
|
|
|
|
|
|
|
|
|
~WatcherWrapper() { parent_.reset(DEBUG_LOCATION, "WatcherWrapper"); } |
|
|
|
~WatcherWrapper() { |
|
|
|
|
|
|
|
auto* parent = parent_.release(); /* ref owned by lambda */ |
|
|
|
|
|
|
|
parent->chand_->work_serializer_->Run( |
|
|
|
|
|
|
|
[parent]() { parent->Unref(DEBUG_LOCATION, "WatcherWrapper"); }, |
|
|
|
|
|
|
|
DEBUG_LOCATION); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OnConnectivityStateChange( |
|
|
|
void OnConnectivityStateChange( |
|
|
|
grpc_connectivity_state new_state, |
|
|
|
grpc_connectivity_state new_state, |
|
|
|