Mark assert failure path as unlikely in codegen.

Also, change an assert to debug assert in callback cpp.
pull/19683/head
Arjun Roy 6 years ago
parent cbc455ecfa
commit b47d22f7f2
  1. 4
      include/grpcpp/impl/codegen/callback_common.h
  2. 2
      include/grpcpp/impl/codegen/core_codegen_interface.h

@ -201,9 +201,11 @@ class CallbackWithSuccessTag
void* ignored = ops_;
// Allow a "false" return value from FinalizeResult to silence the
// callback, just as it silences a CQ tag in the async cases
#ifndef NDEBUG
auto* ops = ops_;
#endif
bool do_callback = ops_->FinalizeResult(&ignored, &ok);
GPR_CODEGEN_ASSERT(ignored == ops);
GPR_CODEGEN_DEBUG_ASSERT(ignored == ops);
if (do_callback) {
CatchingCallback(func_, ok);

@ -144,7 +144,7 @@ extern CoreCodegenInterface* g_core_codegen_interface;
/// Codegen specific version of \a GPR_ASSERT.
#define GPR_CODEGEN_ASSERT(x) \
do { \
if (!(x)) { \
if (GPR_UNLIKELY(!(x))) { \
grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \
} \
} while (0)

Loading…
Cancel
Save