From e714d0fcb876853da7edae71babcae2b0be9659a Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 28 Apr 2020 13:24:23 -0700 Subject: [PATCH] Reviewer comments --- include/grpcpp/impl/codegen/call_op_set.h | 20 +++++++++++++------ .../grpcpp/impl/codegen/interceptor_common.h | 8 ++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 5bfd541c8f4..79fa08ad6dc 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -453,8 +453,12 @@ class CallOpRecvMessage { recv_buf_.Clear(); } } else if (hijacked_) { - if (!hijacked_recv_message_status_) { + if (hijacked_recv_message_failed_) { FinishOpRecvMessageFailureHandler(status); + } else { + // The op was hijacked and it was successful. There is no further action + // to be performed since the message is already in its non-serialized + // form. } } else { FinishOpRecvMessageFailureHandler(status); @@ -465,7 +469,7 @@ class CallOpRecvMessage { InterceptorBatchMethodsImpl* interceptor_methods) { if (message_ == nullptr) return; interceptor_methods->SetRecvMessage(message_, - &hijacked_recv_message_status_); + &hijacked_recv_message_failed_); } void SetFinishInterceptionHookPoint( @@ -496,7 +500,7 @@ class CallOpRecvMessage { ByteBuffer recv_buf_; bool allow_not_getting_message_ = false; bool hijacked_ = false; - bool hijacked_recv_message_status_ = true; + bool hijacked_recv_message_failed_ = false; }; class DeserializeFunc { @@ -559,8 +563,12 @@ class CallOpGenericRecvMessage { recv_buf_.Clear(); } } else if (hijacked_) { - if (!hijacked_recv_message_status_) { + if (hijacked_recv_message_failed_) { FinishOpRecvMessageFailureHandler(status); + } else { + // The op was hijacked and it was successful. There is no further action + // to be performed since the message is already in its non-serialized + // form. } } else { got_message = false; @@ -574,7 +582,7 @@ class CallOpGenericRecvMessage { InterceptorBatchMethodsImpl* interceptor_methods) { if (!deserialize_) return; interceptor_methods->SetRecvMessage(message_, - &hijacked_recv_message_status_); + &hijacked_recv_message_failed_); } void SetFinishInterceptionHookPoint( @@ -607,7 +615,7 @@ class CallOpGenericRecvMessage { ByteBuffer recv_buf_; bool allow_not_getting_message_ = false; bool hijacked_ = false; - bool hijacked_recv_message_status_ = true; + bool hijacked_recv_message_failed_ = false; }; class CallOpClientSendClose { diff --git a/include/grpcpp/impl/codegen/interceptor_common.h b/include/grpcpp/impl/codegen/interceptor_common.h index 9b124197ff0..c87c8034c77 100644 --- a/include/grpcpp/impl/codegen/interceptor_common.h +++ b/include/grpcpp/impl/codegen/interceptor_common.h @@ -166,9 +166,9 @@ class InterceptorBatchMethodsImpl send_trailing_metadata_ = metadata; } - void SetRecvMessage(void* message, bool* hijacked_recv_message_status) { + void SetRecvMessage(void* message, bool* hijacked_recv_message_failed) { recv_message_ = message; - hijacked_recv_message_status_ = hijacked_recv_message_status; + hijacked_recv_message_failed_ = hijacked_recv_message_failed; } void SetRecvInitialMetadata(MetadataMap* map) { @@ -195,7 +195,7 @@ class InterceptorBatchMethodsImpl void FailHijackedRecvMessage() override { GPR_CODEGEN_ASSERT(hooks_[static_cast( experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]); - *hijacked_recv_message_status_ = false; + *hijacked_recv_message_failed_ = true; } // Clears all state @@ -407,7 +407,7 @@ class InterceptorBatchMethodsImpl std::multimap* send_trailing_metadata_ = nullptr; void* recv_message_ = nullptr; - bool* hijacked_recv_message_status_ = nullptr; + bool* hijacked_recv_message_failed_ = nullptr; MetadataMap* recv_initial_metadata_ = nullptr;