Connected channel has ref to channelz

pull/16827/head
ncteisen 6 years ago
parent 17b6c04b89
commit f14c001b64
  1. 9
      src/core/ext/filters/client_channel/subchannel.cc
  2. 15
      src/core/ext/filters/client_channel/subchannel.h

@ -659,7 +659,7 @@ static bool publish_transport_locked(grpc_subchannel* c) {
/* publish */ /* publish */
c->connected_subchannel.reset(grpc_core::New<grpc_core::ConnectedSubchannel>( 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", gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p",
c->connected_subchannel.get(), c); c->connected_subchannel.get(), c);
@ -891,13 +891,16 @@ namespace grpc_core {
ConnectedSubchannel::ConnectedSubchannel( ConnectedSubchannel::ConnectedSubchannel(
grpc_channel_stack* channel_stack, 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), : RefCountedWithTracing<ConnectedSubchannel>(&grpc_trace_stream_refcount),
channel_stack_(channel_stack), channel_stack_(channel_stack),
channelz_subchannel_(channelz_subchannel), channelz_subchannel_(std::move(channelz_subchannel)),
socket_uuid_(socket_uuid) {} socket_uuid_(socket_uuid) {}
ConnectedSubchannel::~ConnectedSubchannel() { ConnectedSubchannel::~ConnectedSubchannel() {
channelz_subchannel_.reset();
GRPC_CHANNEL_STACK_UNREF(channel_stack_, "connected_subchannel_dtor"); GRPC_CHANNEL_STACK_UNREF(channel_stack_, "connected_subchannel_dtor");
} }

@ -85,9 +85,11 @@ class ConnectedSubchannel : public RefCountedWithTracing<ConnectedSubchannel> {
size_t parent_data_size; size_t parent_data_size;
}; };
explicit ConnectedSubchannel(grpc_channel_stack* channel_stack, explicit ConnectedSubchannel(
channelz::SubchannelNode* channelz_subchannel, grpc_channel_stack* channel_stack,
intptr_t socket_uuid); grpc_core::RefCountedPtr<grpc_core::channelz::SubchannelNode>
channelz_subchannel,
intptr_t socket_uuid);
~ConnectedSubchannel(); ~ConnectedSubchannel();
grpc_channel_stack* channel_stack() { return channel_stack_; } 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); void Ping(grpc_closure* on_initiate, grpc_closure* on_ack);
grpc_error* CreateCall(const CallArgs& args, grpc_subchannel_call** call); grpc_error* CreateCall(const CallArgs& args, grpc_subchannel_call** call);
channelz::SubchannelNode* channelz_subchannel() { channelz::SubchannelNode* channelz_subchannel() {
return channelz_subchannel_; return channelz_subchannel_.get();
} }
intptr_t socket_uuid() { return socket_uuid_; } intptr_t socket_uuid() { return socket_uuid_; }
private: private:
grpc_channel_stack* channel_stack_; 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. // 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. // uuid of this subchannel's socket. 0 if this subchannel is not connected.
const intptr_t socket_uuid_; const intptr_t socket_uuid_;
}; };

Loading…
Cancel
Save