Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 20928 #21981

Merged
merged 5 commits into from
Feb 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/core/ext/filters/client_channel/xds/xds_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,16 @@ XdsClient::~XdsClient() { GRPC_COMBINER_UNREF(combiner_, "xds_client"); }
void XdsClient::Orphan() {
shutting_down_ = true;
chand_.reset();
cluster_map_.clear();
endpoint_map_.clear();
// We do not clear cluster_map_ and endpoint_map_ if the xds client was
// created by the XdsResolver because the maps contain refs for watchers which
// in turn hold refs to the loadbalancing policies. At this point, it is
// possible for ADS calls to be in progress. Unreffing the loadbalancing
// policies before those calls are done would lead to issues such as
// https://github.com/grpc/grpc/issues/20928.
if (service_config_watcher_ != nullptr) {
cluster_map_.clear();
endpoint_map_.clear();
}
Unref(DEBUG_LOCATION, "XdsClient::Orphan()");
}

Expand Down Expand Up @@ -1902,13 +1910,13 @@ void XdsClient::NotifyOnError(grpc_error* error) {

void* XdsClient::ChannelArgCopy(void* p) {
XdsClient* xds_client = static_cast<XdsClient*>(p);
xds_client->Ref().release();
xds_client->Ref(DEBUG_LOCATION, "channel arg").release();
return p;
}

void XdsClient::ChannelArgDestroy(void* p) {
XdsClient* xds_client = static_cast<XdsClient*>(p);
xds_client->Unref();
xds_client->Unref(DEBUG_LOCATION, "channel arg");
}

int XdsClient::ChannelArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
Expand Down