Skip to content

Commit

Permalink
Merge pull request grpc#21683 from vjpai/drain_log
Browse files Browse the repository at this point in the history
Log (in debug mode) if CQ destroyed without full draining
  • Loading branch information
vjpai authored Jan 17, 2020
2 parents ae64627 + 570d808 commit 8eea254
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/core/lib/surface/completion_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,14 @@ class CqEventQueue {
};

struct cq_next_data {
~cq_next_data() { GPR_ASSERT(queue.num_items() == 0); }
~cq_next_data() {
GPR_ASSERT(queue.num_items() == 0);
#ifndef NDEBUG
if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
}
#endif
}

/** Completed events for completion-queues of type GRPC_CQ_NEXT */
CqEventQueue queue;
Expand All @@ -267,6 +274,11 @@ struct cq_pluck_data {
~cq_pluck_data() {
GPR_ASSERT(completed_head.next ==
reinterpret_cast<uintptr_t>(&completed_head));
#ifndef NDEBUG
if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
}
#endif
}

/** Completed events for completion-queues of type GRPC_CQ_PLUCK */
Expand Down Expand Up @@ -298,6 +310,15 @@ struct cq_callback_data {
cq_callback_data(
grpc_experimental_completion_queue_functor* shutdown_callback)
: shutdown_callback(shutdown_callback) {}

~cq_callback_data() {
#ifndef NDEBUG
if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
}
#endif
}

/** No actual completed events queue, unlike other types */

/** Number of pending events (+1 if we're not shutdown).
Expand Down

0 comments on commit 8eea254

Please sign in to comment.