diff options
author | ncteisen <ncteisen@gmail.com> | 2018-10-10 12:24:21 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-10-10 18:06:14 -0700 |
commit | f14c001b64d1f3dac9a46189517f1b909124c64d (patch) | |
tree | d29f2acf814189ef6a508f5b14ecc76ff48bdbd3 /src/core | |
parent | 17b6c04b8910dca993a52c24794dd78b26410068 (diff) |
Connected channel has ref to channelz
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ext/filters/client_channel/subchannel.cc | 9 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/subchannel.h | 15 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 38d7a5a6e3..5cd060948d 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -659,7 +659,7 @@ static bool publish_transport_locked(grpc_subchannel* c) { /* publish */ c->connected_subchannel.reset(grpc_core::New<grpc_core::ConnectedSubchannel>( - stk, c->channelz_subchannel.get(), socket_uuid)); + stk, c->channelz_subchannel, socket_uuid)); gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", c->connected_subchannel.get(), c); @@ -891,13 +891,16 @@ namespace grpc_core { ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, - channelz::SubchannelNode* channelz_subchannel, intptr_t socket_uuid) + grpc_core::RefCountedPtr<grpc_core::channelz::SubchannelNode> + channelz_subchannel, + intptr_t socket_uuid) : RefCountedWithTracing<ConnectedSubchannel>(&grpc_trace_stream_refcount), channel_stack_(channel_stack), - channelz_subchannel_(channelz_subchannel), + channelz_subchannel_(std::move(channelz_subchannel)), socket_uuid_(socket_uuid) {} ConnectedSubchannel::~ConnectedSubchannel() { + channelz_subchannel_.reset(); GRPC_CHANNEL_STACK_UNREF(channel_stack_, "connected_subchannel_dtor"); } diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 699f93a8e7..c53b13e37e 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -85,9 +85,11 @@ class ConnectedSubchannel : public RefCountedWithTracing<ConnectedSubchannel> { size_t parent_data_size; }; - explicit ConnectedSubchannel(grpc_channel_stack* channel_stack, - channelz::SubchannelNode* channelz_subchannel, - intptr_t socket_uuid); + explicit ConnectedSubchannel( + grpc_channel_stack* channel_stack, + grpc_core::RefCountedPtr<grpc_core::channelz::SubchannelNode> + channelz_subchannel, + intptr_t socket_uuid); ~ConnectedSubchannel(); grpc_channel_stack* channel_stack() { return channel_stack_; } @@ -97,15 +99,16 @@ class ConnectedSubchannel : public RefCountedWithTracing<ConnectedSubchannel> { void Ping(grpc_closure* on_initiate, grpc_closure* on_ack); grpc_error* CreateCall(const CallArgs& args, grpc_subchannel_call** call); channelz::SubchannelNode* channelz_subchannel() { - return channelz_subchannel_; + return channelz_subchannel_.get(); } intptr_t socket_uuid() { return socket_uuid_; } private: grpc_channel_stack* channel_stack_; - // backpointer to the channelz node in this connected subchannel's + // ref counted pointer to the channelz node in this connected subchannel's // owning subchannel. - channelz::SubchannelNode* channelz_subchannel_; + grpc_core::RefCountedPtr<grpc_core::channelz::SubchannelNode> + channelz_subchannel_; // uuid of this subchannel's socket. 0 if this subchannel is not connected. const intptr_t socket_uuid_; }; |