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 4 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
21 changes: 16 additions & 5 deletions src/core/ext/filters/client_channel/xds/xds_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1746,13 +1746,24 @@ XdsClient::XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
}
}

XdsClient::~XdsClient() { GRPC_COMBINER_UNREF(combiner_, "xds_client"); }
XdsClient::~XdsClient() {
gpr_log(GPR_INFO, "[xds_client %p] Destroying xds client", this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please guard this by checking whether the tracer is enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, alternatively, just remove this line for now, and wait for me to add it as part of #21941. :)

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 +1913,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