Destroy channel args early to remove xds client references

pull/21981/head
Yash Tibrewal 5 years ago
parent 4315503658
commit 683177082e
  1. 3
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  2. 3
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  3. 8
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  4. 9
      src/core/ext/filters/client_channel/xds/xds_client.cc

@ -230,7 +230,6 @@ CdsLb::~CdsLb() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
gpr_log(GPR_INFO, "[cdslb %p] destroying cds LB policy", this);
}
grpc_channel_args_destroy(args_);
}
void CdsLb::ShutdownLocked() {
@ -250,6 +249,8 @@ void CdsLb::ShutdownLocked() {
}
xds_client_.reset();
}
// Destroy the args_ now since they might be holding a ref to the xds client.
grpc_channel_args_destroy(args_);
}
void CdsLb::ResetBackoffLocked() {

@ -699,7 +699,6 @@ XdsLb::~XdsLb() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) {
gpr_log(GPR_INFO, "[xdslb %p] destroying xds LB policy", this);
}
grpc_channel_args_destroy(args_);
}
void XdsLb::ShutdownLocked() {
@ -737,6 +736,8 @@ void XdsLb::ShutdownLocked() {
xds_client_from_channel_.reset();
}
xds_client_.reset();
// Destroy the args now since they might hold a ref to the xds client.
grpc_channel_args_destroy(args_);
}
//

@ -41,11 +41,13 @@ class XdsResolver : public Resolver {
server_name_.reset(gpr_strdup(path));
}
~XdsResolver() override { grpc_channel_args_destroy(args_); }
void StartLocked() override;
void ShutdownLocked() override { xds_client_.reset(); }
void ShutdownLocked() override {
xds_client_.reset();
// Destroy the args now since they might hold a ref to the xds client.
grpc_channel_args_destroy(args_);
}
private:
class ServiceConfigWatcher : public XdsClient::ServiceConfigWatcherInterface {

@ -1746,7 +1746,10 @@ 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);
GRPC_COMBINER_UNREF(combiner_, "xds_client");
}
void XdsClient::Orphan() {
shutting_down_ = true;
@ -1905,13 +1908,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); }

Loading…
Cancel
Save