Fix debug logging of stream refcounts.

pull/19333/head
Mark D. Roth 6 years ago
parent bf46c1198b
commit 16e66c8307
  1. 7
      src/core/ext/filters/client_channel/client_channel.cc
  2. 2
      src/core/lib/transport/transport.cc
  3. 10
      src/core/lib/transport/transport.h

@ -1180,6 +1180,10 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
interested_parties_(grpc_pollset_set_create()), interested_parties_(grpc_pollset_set_create()),
subchannel_pool_(GetSubchannelPool(args->channel_args)), subchannel_pool_(GetSubchannelPool(args->channel_args)),
disconnect_error_(GRPC_ERROR_NONE) { disconnect_error_(GRPC_ERROR_NONE) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
gpr_log(GPR_INFO, "chand=%p: creating client_channel for channel stack %p",
this, owning_stack_);
}
// Initialize data members. // Initialize data members.
grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE, grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE,
"client_channel"); "client_channel");
@ -1259,6 +1263,9 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
} }
ChannelData::~ChannelData() { ChannelData::~ChannelData() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
gpr_log(GPR_INFO, "chand=%p: destroying channel", this);
}
if (resolving_lb_policy_ != nullptr) { if (resolving_lb_policy_ != nullptr) {
grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(), grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(),
interested_parties_); interested_parties_);

@ -90,7 +90,7 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
#endif #endif
GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx);
new (&refcount->refs) grpc_core::RefCount(); new (&refcount->refs) grpc_core::RefCount(1, &grpc_trace_stream_refcount);
new (&refcount->slice_refcount) grpc_slice_refcount( new (&refcount->slice_refcount) grpc_slice_refcount(
grpc_slice_refcount::Type::REGULAR, &refcount->refs, slice_stream_destroy, grpc_slice_refcount::Type::REGULAR, &refcount->refs, slice_stream_destroy,
refcount, &refcount->slice_refcount); refcount, &refcount->slice_refcount);

@ -80,11 +80,13 @@ inline void grpc_stream_ref(grpc_stream_refcount* refcount,
gpr_log(GPR_DEBUG, "%s %p:%p REF %s", refcount->object_type, refcount, gpr_log(GPR_DEBUG, "%s %p:%p REF %s", refcount->object_type, refcount,
refcount->destroy.cb_arg, reason); refcount->destroy.cb_arg, reason);
} }
refcount->refs.RefNonZero(DEBUG_LOCATION, reason);
}
#else #else
inline void grpc_stream_ref(grpc_stream_refcount* refcount) { inline void grpc_stream_ref(grpc_stream_refcount* refcount) {
#endif
refcount->refs.RefNonZero(); refcount->refs.RefNonZero();
} }
#endif
void grpc_stream_destroy(grpc_stream_refcount* refcount); void grpc_stream_destroy(grpc_stream_refcount* refcount);
@ -95,13 +97,17 @@ inline void grpc_stream_unref(grpc_stream_refcount* refcount,
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %s", refcount->object_type, refcount, gpr_log(GPR_DEBUG, "%s %p:%p UNREF %s", refcount->object_type, refcount,
refcount->destroy.cb_arg, reason); refcount->destroy.cb_arg, reason);
} }
if (GPR_UNLIKELY(refcount->refs.Unref(DEBUG_LOCATION, reason))) {
grpc_stream_destroy(refcount);
}
}
#else #else
inline void grpc_stream_unref(grpc_stream_refcount* refcount) { inline void grpc_stream_unref(grpc_stream_refcount* refcount) {
#endif
if (GPR_UNLIKELY(refcount->refs.Unref())) { if (GPR_UNLIKELY(refcount->refs.Unref())) {
grpc_stream_destroy(refcount); grpc_stream_destroy(refcount);
} }
} }
#endif
/* Wrap a buffer that is owned by some stream object into a slice that shares /* Wrap a buffer that is owned by some stream object into a slice that shares
the same refcount */ the same refcount */

Loading…
Cancel
Save