diff --git a/BUILD b/BUILD index 50873bb1d52..aeeca5091d4 100644 --- a/BUILD +++ b/BUILD @@ -1502,6 +1502,9 @@ grpc_cc_library( "//src/core:lib/surface/byte_buffer.cc", "//src/core:lib/surface/byte_buffer_reader.cc", ], + external_deps = [ + "absl/log:check", + ], language = "c++", deps = [ "exec_ctx", @@ -1759,6 +1762,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -1801,6 +1805,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -1847,6 +1852,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -1888,6 +1894,7 @@ grpc_cc_library( "absl/container:flat_hash_map", "absl/container:flat_hash_set", "absl/hash", + "absl/log:check", "absl/random", "absl/status", "absl/status:statusor", diff --git a/src/core/BUILD b/src/core/BUILD index 121dd1e52db..0174a891e77 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -1559,6 +1559,7 @@ grpc_cc_library( ], external_deps = [ "absl/hash", + "absl/log:check", "absl/strings", ], visibility = ["@grpc:alt_grpc_base_legacy"], @@ -1580,6 +1581,9 @@ grpc_cc_library( "lib/slice/slice_buffer.h", "//:include/grpc/slice_buffer.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "slice", "slice_refcount", @@ -2877,6 +2881,9 @@ grpc_cc_library( hdrs = [ "lib/slice/percent_encoding.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "bitset", "slice", @@ -3041,6 +3048,7 @@ grpc_cc_library( ], external_deps = [ "absl/functional:any_invocable", + "absl/log:check", "absl/strings", "absl/types:optional", ], diff --git a/src/core/lib/slice/percent_encoding.cc b/src/core/lib/slice/percent_encoding.cc index bd5d71a0788..8931f1d716d 100644 --- a/src/core/lib/slice/percent_encoding.cc +++ b/src/core/lib/slice/percent_encoding.cc @@ -23,6 +23,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -100,7 +102,7 @@ Slice PercentEncodeSlice(Slice slice, PercentEncodingType type) { *q++ = hex[c & 15]; } } - GPR_ASSERT(q == out.end()); + CHECK(q == out.end()); return Slice(std::move(out)); } diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 90939fa93e4..f2d49e0bf47 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -244,11 +246,11 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin, size_t end) { grpc_slice subset; - GPR_ASSERT(end >= begin); + CHECK(end >= begin); if (source.refcount != nullptr) { // Enforce preconditions - GPR_ASSERT(source.data.refcounted.length >= end); + CHECK(source.data.refcounted.length >= end); // Build the result subset.refcount = source.refcount; @@ -257,7 +259,7 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin, subset.data.refcounted.length = end - begin; } else { // Enforce preconditions - GPR_ASSERT(source.data.inlined.length >= end); + CHECK(source.data.inlined.length >= end); subset.refcount = nullptr; subset.data.inlined.length = static_cast(end - begin); memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin, @@ -296,7 +298,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source, if (source->refcount == nullptr) { // inlined data, copy it out - GPR_ASSERT(source->data.inlined.length >= split); + CHECK(source->data.inlined.length >= split); tail.refcount = nullptr; tail.data.inlined.length = static_cast(source->data.inlined.length - split); @@ -311,7 +313,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source, source->data.refcounted.length = split; } else { size_t tail_length = source->data.refcounted.length - split; - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); if (allow_inline && tail_length < sizeof(tail.data.inlined.bytes) && ref_whom != GRPC_SLICE_REF_TAIL) { // Copy out the bytes - it'll be cheaper than refcounting @@ -371,7 +373,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { grpc_slice head; if (source->refcount == nullptr) { - GPR_ASSERT(source->data.inlined.length >= split); + CHECK(source->data.inlined.length >= split); head.refcount = nullptr; head.data.inlined.length = static_cast(split); @@ -381,7 +383,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { memmove(source->data.inlined.bytes, source->data.inlined.bytes + split, source->data.inlined.length); } else if (allow_inline && split < sizeof(head.data.inlined.bytes)) { - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); head.refcount = nullptr; head.data.inlined.length = static_cast(split); @@ -389,7 +391,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { source->data.refcounted.bytes += split; source->data.refcounted.length -= split; } else { - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); // Build the result head.refcount = source->refcount; diff --git a/src/core/lib/slice/slice.h b/src/core/lib/slice/slice.h index ed9e30c2edb..06388adc19e 100644 --- a/src/core/lib/slice/slice.h +++ b/src/core/lib/slice/slice.h @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -243,7 +244,7 @@ class StaticSlice : public slice_detail::BaseSlice, StaticSlice() = default; explicit StaticSlice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) { - GPR_DEBUG_ASSERT(slice.refcount == grpc_slice_refcount::NoopRefcount()); + DCHECK(slice.refcount == grpc_slice_refcount::NoopRefcount()); } StaticSlice(const StaticSlice& other) @@ -267,7 +268,7 @@ class GPR_MSVC_EMPTY_BASE_CLASS_WORKAROUND MutableSlice MutableSlice() = default; explicit MutableSlice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) { - GPR_DEBUG_ASSERT(slice.refcount == nullptr || slice.refcount->IsUnique()); + DCHECK(slice.refcount == nullptr || slice.refcount->IsUnique()); } ~MutableSlice() { CSliceUnref(c_slice()); } diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index c8e93b7d00c..6ea05cbc157 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -80,7 +82,7 @@ Slice SliceBuffer::JoinIntoSlice() const { GRPC_SLICE_LENGTH(slice_buffer_.slices[i])); ofs += GRPC_SLICE_LENGTH(slice_buffer_.slices[i]); } - GPR_ASSERT(ofs == slice_buffer_.length); + CHECK(ofs == slice_buffer_.length); return Slice(slice); } @@ -330,7 +332,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, return; } - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); if (src->length == n) { grpc_slice_buffer_move_into(src, dst); return; @@ -358,7 +360,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, src, grpc_slice_split_tail_maybe_ref_no_inline( &slice, n, GRPC_SLICE_REF_BOTH)); } - GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n); + CHECK(GRPC_SLICE_LENGTH(slice) == n); grpc_slice_buffer_add(dst, slice); break; } else { // n < slice_len @@ -371,14 +373,14 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, src, grpc_slice_split_tail_maybe_ref_no_inline( &slice, n, GRPC_SLICE_REF_TAIL)); } - GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n); + CHECK(GRPC_SLICE_LENGTH(slice) == n); grpc_slice_buffer_add_indexed(dst, slice); break; } } - GPR_ASSERT(dst->length == output_len); - GPR_ASSERT(src->length == new_input_len); - GPR_ASSERT(src->count > 0); + CHECK(dst->length == output_len); + CHECK(src->length == new_input_len); + CHECK_GT(src->count, 0u); } void grpc_slice_buffer_move_first_no_inline(grpc_slice_buffer* src, size_t n, @@ -399,7 +401,7 @@ void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n, void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n, void* dst) { char* dstp = static_cast(dst); - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); while (n > 0) { grpc_slice slice = grpc_slice_buffer_take_first(src); @@ -425,7 +427,7 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n, void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n, void* dst) { uint8_t* dstp = static_cast(dst); - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); for (size_t i = 0; i < src->count; i++) { grpc_slice slice = src->slices[i]; @@ -442,7 +444,7 @@ void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n, template void grpc_slice_buffer_trim_end_impl(grpc_slice_buffer* sb, size_t n, grpc_slice_buffer* garbage) { - GPR_ASSERT(n <= sb->length); + CHECK(n <= sb->length); sb->length -= n; for (;;) { size_t idx = sb->count - 1; @@ -493,7 +495,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n, grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { grpc_slice slice; - GPR_ASSERT(sb->count > 0); + CHECK_GT(sb->count, 0u); slice = sb->slices[0]; sb->slices++; sb->count--; @@ -503,7 +505,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { } void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb) { - GPR_DEBUG_ASSERT(sb->count > 0); + DCHECK_GT(sb->count, 0u); sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); grpc_core::CSliceUnref(sb->slices[0]); sb->slices++; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 0ab8cd536f0..03d8fbe180d 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -25,6 +25,7 @@ #include #include "absl/hash/hash.h" +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -36,7 +37,7 @@ // Returns a pointer to the first slice in the slice buffer without giving // ownership to or a reference count on that slice. inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) { - GPR_DEBUG_ASSERT(sb->count > 0); + DCHECK_GT(sb->count, 0u); return &sb->slices[0]; } diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc index 1e1efe14f86..2053bf3f8b5 100644 --- a/src/core/lib/surface/byte_buffer_reader.cc +++ b/src/core/lib/surface/byte_buffer_reader.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -93,7 +95,7 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) { memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length); bytes_read += slice_length; grpc_core::CSliceUnref(in_slice); - GPR_ASSERT(bytes_read <= input_size); + CHECK(bytes_read <= input_size); } return out_slice; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index a8eabbd9496..4c425b87470 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -33,6 +33,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -143,8 +144,8 @@ absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) { child_ = arena()->New(parent); parent->InternalRef("child"); - GPR_ASSERT(is_client_); - GPR_ASSERT(!parent->is_client_); + CHECK(is_client_); + CHECK(!parent->is_client_); if (propagation_mask & GRPC_PROPAGATE_DEADLINE) { send_deadline_ = std::min(send_deadline_, parent->send_deadline_); @@ -321,7 +322,7 @@ void Call::ProcessIncomingInitialMetadata(grpc_metadata_batch& md) { HandleCompressionAlgorithmDisabled(compression_algorithm); } // GRPC_COMPRESS_NONE is always set. - GPR_DEBUG_ASSERT(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE)); + DCHECK(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE)); if (GPR_UNLIKELY(!encodings_accepted_by_peer_.IsSet(compression_algorithm))) { if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { HandleCompressionAlgorithmNotAccepted(compression_algorithm); @@ -460,7 +461,7 @@ class FilterStackCall final : public Call { bool is_trailers_only() const override { bool result = is_trailers_only_; - GPR_DEBUG_ASSERT(!result || recv_initial_metadata_.TransportSize() == 0); + DCHECK(!result || recv_initial_metadata_.TransportSize() == 0); return result; } @@ -554,7 +555,7 @@ class FilterStackCall final : public Call { PendingOpString(r & ~mask).c_str(), completion_data_.notify_tag.tag); } - GPR_ASSERT((r & mask) != 0); + CHECK_NE((r & mask), 0); return r == mask; } @@ -704,8 +705,8 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, Arena* arena = channel->CreateArena(); call = new (arena->Alloc(call_alloc_size)) FilterStackCall(arena, *args); - GPR_DEBUG_ASSERT(FromC(call->c_ptr()) == call); - GPR_DEBUG_ASSERT(FromCallStack(call->call_stack()) == call); + DCHECK(FromC(call->c_ptr()) == call); + DCHECK(FromCallStack(call->call_stack()) == call); *out_call = call->c_ptr(); grpc_slice path = grpc_empty_slice(); ScopedContext ctx(call); @@ -778,9 +779,9 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, call->CancelWithError(error); } if (args->cq != nullptr) { - GPR_ASSERT(args->pollset_set_alternative == nullptr && - "Only one of 'cq' and 'pollset_set_alternative' should be " - "non-nullptr."); + CHECK(args->pollset_set_alternative == nullptr) + << "Only one of 'cq' and 'pollset_set_alternative' should be " + "non-nullptr."; GRPC_CQ_INTERNAL_REF(args->cq, "bind"); call->pollent_ = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq)); @@ -817,7 +818,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, } void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) { - GPR_ASSERT(cq); + CHECK(cq); if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) { Crash("A pollset_set is already registered for this call."); @@ -867,7 +868,7 @@ void FilterStackCall::ExternalUnref() { MaybeUnpublishFromParent(); - GPR_ASSERT(!destroy_called_); + CHECK(!destroy_called_); destroy_called_ = true; bool cancel = gpr_atm_acq_load(&received_final_op_atm_) == 0; if (cancel) { @@ -1358,7 +1359,7 @@ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady( while (true) { gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_); // Should only receive initial metadata once - GPR_ASSERT(rsr_bctlp != 1); + CHECK_NE(rsr_bctlp, 1); if (rsr_bctlp == 0) { // We haven't seen initial metadata and messages before, thus initial // metadata is received first. @@ -1412,7 +1413,7 @@ namespace { void EndOpImmediately(grpc_completion_queue* cq, void* notify_tag, bool is_notify_tag_closure) { if (!is_notify_tag_closure) { - GPR_ASSERT(grpc_cq_begin_op(cq, notify_tag)); + CHECK(grpc_cq_begin_op(cq, notify_tag)); grpc_cq_end_op( cq, notify_tag, absl::OkStatus(), [](void*, grpc_cq_completion* completion) { gpr_free(completion); }, @@ -1783,7 +1784,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops, InternalRef("completion"); if (!is_notify_tag_closure) { - GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag)); + CHECK(grpc_cq_begin_op(cq_, notify_tag)); } bctl->set_pending_ops(pending_ops); @@ -2064,7 +2065,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall { class Completion { public: Completion() : index_(kNullIndex) {} - ~Completion() { GPR_ASSERT(index_ == kNullIndex); } + ~Completion() { CHECK(index_ == kNullIndex); } explicit Completion(uint8_t index) : index_(index) {} Completion(const Completion& other) = delete; Completion& operator=(const Completion& other) = delete; @@ -2072,7 +2073,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall { other.index_ = kNullIndex; } Completion& operator=(Completion&& other) noexcept { - GPR_ASSERT(index_ == kNullIndex); + CHECK(index_ == kNullIndex); index_ = other.index_; other.index_ = kNullIndex; return *this; @@ -2257,13 +2258,13 @@ class PromiseBasedCall : public BasicPromiseBasedCall { if (reason == PendingOp::kReceiveMessage) is_recv_message = true; auto prev = state.fetch_or(PendingOpBit(reason), std::memory_order_relaxed); - GPR_ASSERT((prev & PendingOpBit(reason)) == 0); + CHECK_EQ((prev & PendingOpBit(reason)), 0u); } CompletionState RemovePendingBit(PendingOp reason) { const uint32_t mask = ~PendingOpBit(reason); auto prev = state.fetch_and(mask, std::memory_order_acq_rel); - GPR_ASSERT((prev & PendingOpBit(reason)) != 0); + CHECK_NE((prev & PendingOpBit(reason)), 0u); switch (prev & mask) { case kOpFailed: return kFailure; @@ -2324,7 +2325,7 @@ grpc_error_handle MakePromiseBasedCall(grpc_call_create_args* args, auto* arena = channel->CreateArena(); PromiseBasedCall* call = arena->New(arena, args); *out_call = call->c_ptr(); - GPR_DEBUG_ASSERT(Call::FromC(*out_call) == call); + DCHECK(Call::FromC(*out_call) == call); return absl::OkStatus(); } @@ -2371,7 +2372,7 @@ PromiseBasedCall::Completion PromiseBasedCall::AddOpToCompletion( gpr_log(GPR_INFO, "%s[call] AddOpToCompletion %s %s", DebugTag().c_str(), CompletionString(completion).c_str(), PendingOpString(reason)); } - GPR_ASSERT(completion.has_value()); + CHECK(completion.has_value()); completion_info_[completion.index()].pending.AddPendingBit(reason); return Completion(completion.index()); } @@ -2398,7 +2399,7 @@ void PromiseBasedCall::FinishOpOnCompletion(Completion* completion, PendingOpString(reason)); } const uint8_t i = completion->TakeIndex(); - GPR_ASSERT(i < GPR_ARRAY_SIZE(completion_info_)); + CHECK(i < GPR_ARRAY_SIZE(completion_info_)); CompletionInfo::Pending& pending = completion_info_[i].pending; bool success; switch (pending.RemovePendingBit(reason)) { @@ -2579,9 +2580,9 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { : grpc_polling_entity{})) { global_stats().IncrementClientCallsCreated(); if (args->cq != nullptr) { - GPR_ASSERT(args->pollset_set_alternative == nullptr && - "Only one of 'cq' and 'pollset_set_alternative' should be " - "non-nullptr."); + CHECK(args->pollset_set_alternative == nullptr) + << "Only one of 'cq' and 'pollset_set_alternative' should be " + "non-nullptr."; } ScopedContext context(this); args->channel->channel_stack()->stats_plugin_group->AddClientCallTracers( @@ -2741,12 +2742,12 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { Latch cancel_error_; Latch was_cancelled_latch_; }; - GPR_ASSERT(call_args.server_initial_metadata == - &server_initial_metadata_.sender); - GPR_ASSERT(call_args.client_to_server_messages == - &client_to_server_messages_.receiver); - GPR_ASSERT(call_args.server_to_client_messages == - &server_to_client_messages_.sender); + CHECK(call_args.server_initial_metadata == + &server_initial_metadata_.sender); + CHECK(call_args.client_to_server_messages == + &client_to_server_messages_.receiver); + CHECK(call_args.server_to_client_messages == + &server_to_client_messages_.sender); call_args.client_initial_metadata_outstanding.Complete(true); return MakeRefCounted( this, std::move(call_args.client_initial_metadata)); @@ -3951,12 +3952,12 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, metadata->Set(GrpcMessageMetadata(), Slice(grpc_slice_copy(*details))); } - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); return [this, metadata = std::move(metadata)]() mutable { - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); return [this, metadata = std::move(metadata)]() mutable -> Poll { - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); PushServerTrailingMetadata(std::move(metadata)); return Success{}; }; @@ -3964,7 +3965,7 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, }); auto recv_message = MaybeOp(ops, got_ops[GRPC_OP_RECV_MESSAGE], [this](const grpc_op& op) { - GPR_ASSERT(recv_message_ == nullptr); + CHECK_EQ(recv_message_, nullptr); recv_message_ = op.data.recv_message.recv_message; return [this]() mutable { return Map(client_to_server_messages_.receiver.Next(), @@ -4087,7 +4088,7 @@ grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) { grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) { GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); if (call == nullptr) { return GRPC_CALL_ERROR; } @@ -4105,7 +4106,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c, "grpc_call_cancel_with_status(" "c=%p, status=%d, description=%s, reserved=%p)", 4, (c, (int)status, description, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); if (c == nullptr) { return GRPC_CALL_ERROR; } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e70e1d001b9..827d37f06b6 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -16,6 +16,8 @@ #include "src/core/lib/surface/channel.h" +#include "absl/log/check.h" + #include #include #include @@ -98,7 +100,7 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel, grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved) { - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->CreateCall( @@ -116,7 +118,7 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method, GRPC_API_TRACE( "grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)", 4, (channel, method, host, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->RegisterCall(method, host); @@ -139,7 +141,7 @@ grpc_call* grpc_channel_create_registered_call( (channel, parent_call, (unsigned)propagation_mask, completion_queue, registered_call_handle, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->CreateCall( @@ -213,6 +215,6 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq, grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4, (channel, cq, tag, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); grpc_core::Channel::FromC(channel)->Ping(cq, tag); } diff --git a/src/core/lib/surface/channel_create.cc b/src/core/lib/surface/channel_create.cc index 0fccd09a45b..0ad87af1f62 100644 --- a/src/core/lib/surface/channel_create.cc +++ b/src/core/lib/surface/channel_create.cc @@ -14,6 +14,8 @@ // limitations under the License. // +#include "absl/log/check.h" + #include #include #include @@ -103,6 +105,6 @@ grpc_channel* grpc_lame_client_channel_create(const char* target, auto channel = grpc_core::ChannelCreate(target == nullptr ? "" : target, std::move(args), GRPC_CLIENT_LAME_CHANNEL, nullptr); - GPR_ASSERT(channel.ok()); + CHECK(channel.ok()); return channel->release()->c_ptr(); } diff --git a/src/core/lib/surface/channel_init.cc b/src/core/lib/surface/channel_init.cc index 59aa35e3761..b94b189ffea 100644 --- a/src/core/lib/surface/channel_init.cc +++ b/src/core/lib/surface/channel_init.cc @@ -26,6 +26,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -137,9 +138,9 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig( } filter_to_registration[registration->filter_] = registration.get(); if (registration->terminal_) { - GPR_ASSERT(registration->after_.empty()); - GPR_ASSERT(registration->before_.empty()); - GPR_ASSERT(!registration->before_all_); + CHECK(registration->after_.empty()); + CHECK(registration->before_.empty()); + CHECK(!registration->before_all_); terminal_filters.emplace_back( registration->filter_, nullptr, std::move(registration->predicates_), registration->skip_v3_, registration->registration_source_); @@ -149,7 +150,7 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig( } for (const auto& registration : registrations) { if (registration->terminal_) continue; - GPR_ASSERT(filter_to_registration.count(registration->filter_) > 0); + CHECK_GT(filter_to_registration.count(registration->filter_), 0u); for (F after : registration->after_) { if (filter_to_registration.count(after) == 0) { gpr_log( diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h index 5f1bacdeff1..fcfef582994 100644 --- a/src/core/lib/surface/channel_init.h +++ b/src/core/lib/surface/channel_init.h @@ -27,6 +27,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include #include @@ -217,7 +218,7 @@ class ChannelInit { PostProcessorSlot slot, PostProcessor post_processor) { auto& slot_value = post_processors_[type][static_cast(slot)]; - GPR_ASSERT(slot_value == nullptr); + CHECK(slot_value == nullptr); slot_value = std::move(post_processor); } diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 0f76f4fd2a9..5d777b50741 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" @@ -178,7 +179,7 @@ grpc_error_handle non_polling_poller_kick( void non_polling_poller_shutdown(grpc_pollset* pollset, grpc_closure* closure) { non_polling_poller* p = reinterpret_cast(pollset); - GPR_ASSERT(closure != nullptr); + CHECK_NE(closure, nullptr); p->shutdown = closure; if (p->root == nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, absl::OkStatus()); @@ -256,7 +257,7 @@ class CqEventQueue { struct cq_next_data { ~cq_next_data() { - GPR_ASSERT(queue.num_items() == 0); + CHECK_EQ(queue.num_items(), 0); #ifndef NDEBUG if (pending_events.load(std::memory_order_acquire) != 0) { gpr_log(GPR_ERROR, "Destroying CQ without draining it fully."); @@ -286,8 +287,7 @@ struct cq_pluck_data { } ~cq_pluck_data() { - GPR_ASSERT(completed_head.next == - reinterpret_cast(&completed_head)); + CHECK(completed_head.next == reinterpret_cast(&completed_head)); #ifndef NDEBUG if (pending_events.load(std::memory_order_acquire) != 0) { gpr_log(GPR_ERROR, "Destroying CQ without draining it fully."); @@ -655,7 +655,7 @@ static void cq_check_tag(grpc_completion_queue* cq, void* tag, bool lock_cq) { gpr_mu_unlock(cq->mu); } - GPR_ASSERT(found); + CHECK(found); } #else static void cq_check_tag(grpc_completion_queue* /*cq*/, void* /*tag*/, @@ -905,7 +905,7 @@ class ExecCtxNext : public grpc_core::ExecCtx { static_cast(check_ready_to_finish_arg_); grpc_completion_queue* cq = a->cq; cq_next_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(a->stolen_completion == nullptr); + CHECK_EQ(a->stolen_completion, nullptr); intptr_t current_last_seen_things_queued_ever = cqd->things_queued_ever.load(std::memory_order_relaxed); @@ -962,7 +962,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, 5, (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); dump_pending_tags(cq); @@ -1068,7 +1068,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret); GRPC_CQ_INTERNAL_UNREF(cq, "next"); - GPR_ASSERT(is_finished_arg.stolen_completion == nullptr); + CHECK_EQ(is_finished_arg.stolen_completion, nullptr); return ret; } @@ -1082,8 +1082,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, static void cq_finish_shutdown_next(grpc_completion_queue* cq) { cq_next_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(cqd->shutdown_called); - GPR_ASSERT(cqd->pending_events.load(std::memory_order_relaxed) == 0); + CHECK(cqd->shutdown_called); + CHECK_EQ(cqd->pending_events.load(std::memory_order_relaxed), 0); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); } @@ -1156,7 +1156,7 @@ class ExecCtxPluck : public grpc_core::ExecCtx { grpc_completion_queue* cq = a->cq; cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(a->stolen_completion == nullptr); + CHECK_EQ(a->stolen_completion, nullptr); gpr_atm current_last_seen_things_queued_ever = cqd->things_queued_ever.load(std::memory_order_relaxed); if (current_last_seen_things_queued_ever != @@ -1207,7 +1207,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag, (cq, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); } - GPR_ASSERT(!reserved); + CHECK(!reserved); dump_pending_tags(cq); @@ -1298,7 +1298,7 @@ done: GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret); GRPC_CQ_INTERNAL_UNREF(cq, "pluck"); - GPR_ASSERT(is_finished_arg.stolen_completion == nullptr); + CHECK_EQ(is_finished_arg.stolen_completion, nullptr); return ret; } @@ -1311,8 +1311,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) { cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(cqd->shutdown_called); - GPR_ASSERT(!cqd->shutdown.load(std::memory_order_relaxed)); + CHECK(cqd->shutdown_called); + CHECK(!cqd->shutdown.load(std::memory_order_relaxed)); cqd->shutdown.store(true, std::memory_order_relaxed); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); @@ -1348,7 +1348,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); auto* callback = cqd->shutdown_callback; - GPR_ASSERT(cqd->shutdown_called); + CHECK(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); if (grpc_iomgr_is_any_background_poller_thread()) { diff --git a/src/core/lib/surface/completion_queue_factory.cc b/src/core/lib/surface/completion_queue_factory.cc index cb9a1b55d42..486cc5f00ec 100644 --- a/src/core/lib/surface/completion_queue_factory.cc +++ b/src/core/lib/surface/completion_queue_factory.cc @@ -18,6 +18,8 @@ #include "src/core/lib/surface/completion_queue_factory.h" +#include "absl/log/check.h" + #include #include #include @@ -47,8 +49,8 @@ static const grpc_completion_queue_factory g_default_cq_factory = { const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( const grpc_completion_queue_attributes* attributes) { - GPR_ASSERT(attributes->version >= 1 && - attributes->version <= GRPC_CQ_CURRENT_VERSION); + CHECK(attributes->version >= 1 && + attributes->version <= GRPC_CQ_CURRENT_VERSION); // The default factory can handle version 1 of the attributes structure. We // may have to change this as more fields are added to the structure @@ -61,7 +63,7 @@ const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, nullptr}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -69,7 +71,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -78,7 +80,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { grpc_completion_queue* grpc_completion_queue_create_for_callback( grpc_completion_queue_functor* shutdown_callback, void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = { 2, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -88,6 +90,6 @@ grpc_completion_queue* grpc_completion_queue_create( const grpc_completion_queue_factory* factory, const grpc_completion_queue_attributes* attr, void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); return factory->vtable->create(factory, attr); } diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index 0ee4cd61312..104924d42b7 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -19,6 +19,7 @@ #include "src/core/lib/surface/legacy_channel.h" #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -166,8 +167,8 @@ grpc_call* LegacyChannel::CreateCall( grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative, Slice path, absl::optional authority, Timestamp deadline, bool registered_method) { - GPR_ASSERT(is_client_); - GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr)); + CHECK(is_client_); + CHECK(!(cq != nullptr && pollset_set_alternative != nullptr)); grpc_call_create_args args; args.channel = Ref(); args.server = nullptr; @@ -213,7 +214,7 @@ class LegacyChannel::StateWatcher final : public DualRefCounted { cq_(cq), tag_(tag), state_(last_observed_state) { - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); GRPC_CLOSURE_INIT(&on_complete_, WatchComplete, this, nullptr); ClientChannelFilter* client_channel = channel_->GetClientChannelFilter(); if (client_channel == nullptr) { @@ -343,14 +344,14 @@ void LegacyChannel::AddConnectivityWatcher( grpc_connectivity_state initial_state, OrphanablePtr watcher) { auto* client_channel = GetClientChannelFilter(); - GPR_ASSERT(client_channel != nullptr); + CHECK_NE(client_channel, nullptr); client_channel->AddConnectivityWatcher(initial_state, std::move(watcher)); } void LegacyChannel::RemoveConnectivityWatcher( AsyncConnectivityStateWatcherInterface* watcher) { auto* client_channel = GetClientChannelFilter(); - GPR_ASSERT(client_channel != nullptr); + CHECK_NE(client_channel, nullptr); client_channel->RemoveConnectivityWatcher(watcher); } @@ -394,7 +395,7 @@ void LegacyChannel::Ping(grpc_completion_queue* cq, void* tag) { grpc_transport_op* op = grpc_make_transport_op(nullptr); op->send_ping.on_ack = &pr->closure; op->bind_pollset = grpc_cq_pollset(cq); - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); grpc_channel_element* top_elem = grpc_channel_stack_element(channel_stack_.get(), 0); top_elem->filter->start_transport_op(top_elem, op); diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h index 13f44a52fdf..0607abd1e00 100644 --- a/src/core/lib/surface/validate_metadata.h +++ b/src/core/lib/surface/validate_metadata.h @@ -23,6 +23,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -58,7 +59,7 @@ inline int grpc_key_is_binary_header(const uint8_t* buf, size_t length) { return 0 == memcmp(buf + length - 4, "-bin", 4); } inline int grpc_is_refcounted_slice_binary_header(const grpc_slice& slice) { - GPR_DEBUG_ASSERT(slice.refcount != nullptr); + DCHECK_NE(slice.refcount, nullptr); return grpc_key_is_binary_header(slice.data.refcounted.bytes, slice.data.refcounted.length); } diff --git a/src/core/server/server.cc b/src/core/server/server.cc index c43792935af..04d0f52da3e 100644 --- a/src/core/server/server.cc +++ b/src/core/server/server.cc @@ -32,6 +32,7 @@ #include "absl/cleanup/cleanup.h" #include "absl/container/flat_hash_map.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -237,7 +238,7 @@ struct Server::RequestedCall { Timestamp deadline = GetContext()->deadline(); switch (type) { case RequestedCall::Type::BATCH_CALL: - GPR_ASSERT(!payload.has_value()); + CHECK(!payload.has_value()); data.batch.details->host = CSliceRef(md.get_pointer(HttpAuthorityMetadata())->c_slice()); data.batch.details->method = @@ -294,9 +295,9 @@ class Server::RealRequestMatcherFilterStack : public RequestMatcherInterface { ~RealRequestMatcherFilterStack() override { for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) { - GPR_ASSERT(queue.Pop() == nullptr); + CHECK_EQ(queue.Pop(), nullptr); } - GPR_ASSERT(pending_.empty()); + CHECK(pending_.empty()); } void ZombifyPending() override { @@ -426,7 +427,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface { ~RealRequestMatcherPromises() override { for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) { - GPR_ASSERT(queue.Pop() == nullptr); + CHECK_EQ(queue.Pop(), nullptr); } } @@ -563,7 +564,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface { if (!result.compare_exchange_strong(expected, new_value, std::memory_order_acq_rel, std::memory_order_acquire)) { - GPR_ASSERT(new_value->value().TakeCall() == requested_call); + CHECK(new_value->value().TakeCall() == requested_call); delete new_value; return false; } @@ -600,7 +601,7 @@ class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface { break; } } - GPR_ASSERT(idx < server->cqs_.size()); + CHECK(idx < server->cqs_.size()); cq_idx_ = idx; } @@ -646,9 +647,9 @@ class Server::AllocatingRequestMatcherBatch absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); }); if (still_running) { BatchCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), static_cast(call_info.tag), nullptr, - nullptr) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), + static_cast(call_info.tag), + nullptr, nullptr) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast(call_info.tag), call_info.cq, call_info.call, call_info.initial_metadata, call_info.details); @@ -662,9 +663,9 @@ class Server::AllocatingRequestMatcherBatch ArenaPromise> MatchRequest( size_t /*start_request_queue_index*/) override { BatchCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), static_cast(call_info.tag), nullptr, nullptr) == - GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), + static_cast(call_info.tag), + nullptr, nullptr) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast(call_info.tag), call_info.cq, call_info.call, call_info.initial_metadata, call_info.details); @@ -692,9 +693,9 @@ class Server::AllocatingRequestMatcherRegistered absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); }); if (server()->ShutdownRefOnRequest()) { RegisteredCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), call_info.tag, call_info.optional_payload, - registered_method_) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest( + cq(), call_info.tag, call_info.optional_payload, + registered_method_) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall(call_info.tag, call_info.cq, call_info.call, call_info.initial_metadata, registered_method_, @@ -709,9 +710,9 @@ class Server::AllocatingRequestMatcherRegistered ArenaPromise> MatchRequest( size_t /*start_request_queue_index*/) override { RegisteredCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), call_info.tag, call_info.optional_payload, - registered_method_) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), call_info.tag, + call_info.optional_payload, + registered_method_) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( call_info.tag, call_info.cq, call_info.call, call_info.initial_metadata, registered_method_, call_info.deadline, call_info.optional_payload); @@ -736,7 +737,7 @@ class ChannelBroadcaster { // Copies over the channels from the locked server. void FillChannelsLocked(std::vector> channels) { - GPR_DEBUG_ASSERT(channels_.empty()); + DCHECK(channels_.empty()); channels_ = std::move(channels); } @@ -955,7 +956,7 @@ void Server::SetRegisteredMethodAllocator( void Server::SetBatchMethodAllocator( grpc_completion_queue* cq, std::function allocator) { - GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr); + DCHECK(unregistered_request_matcher_ == nullptr); unregistered_request_matcher_ = std::make_unique(this, cq, std::move(allocator)); @@ -1007,7 +1008,7 @@ void Server::FailCall(size_t cq_idx, RequestedCall* rc, grpc_error_handle error) { *rc->call = nullptr; rc->initial_metadata->count = 0; - GPR_ASSERT(!error.ok()); + CHECK(!error.ok()); grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc, &rc->completion); } @@ -1101,7 +1102,7 @@ void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) { starting_cv_.Wait(&mu_global_); } // Stay locked, and gather up some stuff to do. - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); if (shutdown_published_) { grpc_cq_end_op(cq, tag, absl::OkStatus(), DonePublishedShutdown, nullptr, new grpc_cq_completion); @@ -1162,8 +1163,8 @@ void Server::SendGoaways() { void Server::Orphan() { { MutexLock lock(&mu_global_); - GPR_ASSERT(ShutdownCalled() || listeners_.empty()); - GPR_ASSERT(listeners_destroyed_ == listeners_.size()); + CHECK(ShutdownCalled() || listeners_.empty()); + CHECK(listeners_destroyed_ == listeners_.size()); } Unref(); } @@ -1341,7 +1342,7 @@ void Server::ChannelData::InitTransport(RefCountedPtr server, ++accept_stream_types; transport->server_transport()->SetAcceptor(this); } - GPR_ASSERT(accept_stream_types == 1); + CHECK_EQ(accept_stream_types, 1); op->start_connectivity_watch = MakeOrphanable(this); if (server_->ShutdownCalled()) { op->disconnect_with_error = GRPC_ERROR_CREATE("Server shutdown"); @@ -1403,8 +1404,8 @@ void Server::ChannelData::AcceptStream(void* arg, Transport* /*transport*/, grpc_error_handle error = grpc_call_create(&args, &call); grpc_call_stack* call_stack = grpc_call_get_call_stack(call); if (call_stack == nullptr) { // Promise based calls do not have a call stack - GPR_ASSERT(error.ok()); - GPR_ASSERT(IsPromiseBasedServerCallEnabled()); + CHECK(error.ok()); + CHECK(IsPromiseBasedServerCallEnabled()); return; } else { grpc_call_element* elem = grpc_call_stack_element(call_stack, 0); @@ -1598,7 +1599,7 @@ void Server::ChannelData::FinishDestroy(void* arg, void Server::ChannelData::Destroy() { if (!list_position_.has_value()) return; - GPR_ASSERT(server_ != nullptr); + CHECK(server_ != nullptr); server_->channels_.erase(*list_position_); list_position_.reset(); server_->Ref().release(); @@ -1620,8 +1621,8 @@ void Server::ChannelData::Destroy() { grpc_error_handle Server::ChannelData::InitChannelElement( grpc_channel_element* elem, grpc_channel_element_args* args) { - GPR_ASSERT(args->is_first); - GPR_ASSERT(!args->is_last); + CHECK(args->is_first); + CHECK(!args->is_last); new (elem->channel_data) ChannelData(); return absl::OkStatus(); } @@ -1648,7 +1649,7 @@ Server::CallData::CallData(grpc_call_element* elem, } Server::CallData::~CallData() { - GPR_ASSERT(state_.load(std::memory_order_relaxed) != CallState::PENDING); + CHECK(state_.load(std::memory_order_relaxed) != CallState::PENDING); grpc_metadata_array_destroy(&initial_metadata_); grpc_byte_buffer_destroy(payload_); } @@ -1699,8 +1700,8 @@ void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) { std::swap(*rc->initial_metadata, initial_metadata_); switch (rc->type) { case RequestedCall::Type::BATCH_CALL: - GPR_ASSERT(host_.has_value()); - GPR_ASSERT(path_.has_value()); + CHECK(host_.has_value()); + CHECK(path_.has_value()); rc->data.batch.details->host = CSliceRef(host_->c_slice()); rc->data.batch.details->method = CSliceRef(path_->c_slice()); rc->data.batch.details->deadline = @@ -1914,7 +1915,7 @@ void grpc_server_register_completion_queue(grpc_server* server, GRPC_API_TRACE( "grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3, (server, cq, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); auto cq_type = grpc_get_cq_completion_type(cq); if (cq_type != GRPC_CQ_NEXT && cq_type != GRPC_CQ_CALLBACK) { gpr_log(GPR_INFO,