diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 49d72b5e6d7..60cbb244678 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -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; @@ -267,6 +274,11 @@ struct cq_pluck_data { ~cq_pluck_data() { GPR_ASSERT(completed_head.next == reinterpret_cast(&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 */ @@ -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).