From 81eceb31ccab4a91e84ef06833d43d8c9e49de0f Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Thu, 12 Jan 2017 14:27:01 -0800
Subject: [PATCH] Remove bogus assert

---
 include/grpc++/impl/codegen/client_unary_call.h     |  9 ++++++++-
 include/grpc++/impl/codegen/core_codegen.h          |  3 ++-
 .../grpc++/impl/codegen/core_codegen_interface.h    | 13 +++++++------
 .../transport/chttp2/transport/chttp2_transport.c   |  2 --
 src/cpp/common/core_codegen.cc                      |  6 ++++--
 5 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h
index 70d65549c8..201e52ae07 100644
--- a/include/grpc++/impl/codegen/client_unary_call.h
+++ b/include/grpc++/impl/codegen/client_unary_call.h
@@ -69,7 +69,14 @@ Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method,
   ops.ClientSendClose();
   ops.ClientRecvStatus(context, &status);
   call.PerformOps(&ops);
-  GPR_CODEGEN_ASSERT((cq.Pluck(&ops) && ops.got_message) || !status.ok());
+  if (cq.Pluck(&ops)) {
+    if (!ops.got_message && status.ok()) {
+      return Status(StatusCode::UNIMPLEMENTED,
+                    "No message returned for unary request");
+    }
+  } else {
+    GPR_CODEGEN_ASSERT(!status.ok());
+  }
   return status;
 }
 
diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h
index b5ab26154e..754bf14b25 100644
--- a/include/grpc++/impl/codegen/core_codegen.h
+++ b/include/grpc++/impl/codegen/core_codegen.h
@@ -94,7 +94,8 @@ class CoreCodegen : public CoreCodegenInterface {
   virtual const Status& ok() override;
   virtual const Status& cancelled() override;
 
-  void assert_fail(const char* failed_assertion) override;
+  void assert_fail(const char* failed_assertion, const char* file,
+                   int line) override;
 };
 
 }  // namespace grpc
diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h
index 9c1af972b3..45ea040303 100644
--- a/include/grpc++/impl/codegen/core_codegen_interface.h
+++ b/include/grpc++/impl/codegen/core_codegen_interface.h
@@ -56,7 +56,8 @@ namespace grpc {
 class CoreCodegenInterface {
  public:
   /// Upon a failed assertion, log the error.
-  virtual void assert_fail(const char* failed_assertion) = 0;
+  virtual void assert_fail(const char* failed_assertion, const char* file,
+                           int line) = 0;
 
   virtual grpc_completion_queue* grpc_completion_queue_create(
       void* reserved) = 0;
@@ -117,11 +118,11 @@ class CoreCodegenInterface {
 extern CoreCodegenInterface* g_core_codegen_interface;
 
 /// Codegen specific version of \a GPR_ASSERT.
-#define GPR_CODEGEN_ASSERT(x)                          \
-  do {                                                 \
-    if (!(x)) {                                        \
-      grpc::g_core_codegen_interface->assert_fail(#x); \
-    }                                                  \
+#define GPR_CODEGEN_ASSERT(x)                                              \
+  do {                                                                     \
+    if (!(x)) {                                                            \
+      grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \
+    }                                                                      \
   } while (0)
 
 }  // namespace grpc
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
index 1e9f4f1656..eb9ffd6773 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
@@ -1075,8 +1075,6 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
     on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
     s->fetching_send_message_finished = add_closure_barrier(op->on_complete);
     if (s->write_closed) {
-      gpr_log(GPR_DEBUG, "write_closed_error=%s",
-              grpc_error_string(s->write_closed_error));
       grpc_chttp2_complete_closure_step(
           exec_ctx, t, s, &s->fetching_send_message_finished,
           GRPC_ERROR_CREATE_REFERENCING(
diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc
index a09e08ef4c..36e4c89354 100644
--- a/src/cpp/common/core_codegen.cc
+++ b/src/cpp/common/core_codegen.cc
@@ -163,8 +163,10 @@ gpr_timespec CoreCodegen::gpr_time_0(gpr_clock_type type) {
   return ::gpr_time_0(type);
 }
 
-void CoreCodegen::assert_fail(const char* failed_assertion) {
-  gpr_log(GPR_ERROR, "assertion failed: %s", failed_assertion);
+void CoreCodegen::assert_fail(const char* failed_assertion, const char* file,
+                              int line) {
+  gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "assertion failed: %s",
+          failed_assertion);
   abort();
 }
 
-- 
GitLab