From 6f05a711e651196672450693493dee181368697d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 10 Oct 2018 23:26:44 -0700 Subject: Adding a test --- include/grpcpp/impl/codegen/call.h | 13 +++++++------ include/grpcpp/impl/codegen/completion_queue.h | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'include/grpcpp') diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h index b2f133a94e..1f9128d8db 100644 --- a/include/grpcpp/impl/codegen/call.h +++ b/include/grpcpp/impl/codegen/call.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CODEGEN_CALL_H #define GRPCPP_IMPL_CODEGEN_CALL_H +#include #include #include #include @@ -412,7 +413,7 @@ class CallOpRecvMessage { void SetFinishInterceptionHookPoint( experimental::InterceptorBatchMethods* interceptor_methods) { - if (message_ == nullptr || !got_message) return; + if (!got_message) return; interceptor_methods->AddInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_MESSAGE); } @@ -507,7 +508,7 @@ class CallOpGenericRecvMessage { void SetFinishInterceptionHookPoint( experimental::InterceptorBatchMethods* interceptor_methods) { - if (!deserialize_ || !got_message) return; + if (!got_message) return; interceptor_methods->AddInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_MESSAGE); } @@ -651,7 +652,6 @@ class CallOpRecvInitialMetadata { void FinishOp(bool* status) { if (metadata_map_ == nullptr || hijacked_) return; - metadata_map_ = nullptr; } void SetInterceptionHookPoint( @@ -662,6 +662,7 @@ class CallOpRecvInitialMetadata { if (metadata_map_ == nullptr) return; interceptor_methods->AddInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA); + metadata_map_ = nullptr; } void SetHijackingState( @@ -719,7 +720,6 @@ class CallOpClientRecvStatus { if (debug_error_string_ != nullptr) { g_core_codegen_interface->gpr_free((void*)debug_error_string_); } - recv_status_ = nullptr; } void SetInterceptionHookPoint( @@ -732,6 +732,7 @@ class CallOpClientRecvStatus { experimental::InterceptionHookPoints::POST_RECV_STATUS); interceptor_methods->SetRecvStatus(recv_status_); interceptor_methods->SetRecvTrailingMetadata(metadata_map_->arr()); + recv_status_ = nullptr; } void SetHijackingState( @@ -912,7 +913,7 @@ class InterceptorBatchMethodsImpl virtual void AddInterceptionHookPoint( experimental::InterceptionHookPoints type) override { - hooks_[static_cast(type)]; + hooks_[static_cast(type)] = true; } virtual void GetSendMessage(grpc_byte_buffer** buf) override { @@ -1187,13 +1188,13 @@ class CallOpSet : public CallOpSetInterface, } /* Returns true if no interceptors need to be run */ bool RunInterceptorsPostRecv() { + interceptor_methods_.SetReverse(); this->Op1::SetFinishInterceptionHookPoint(&interceptor_methods_); this->Op2::SetFinishInterceptionHookPoint(&interceptor_methods_); this->Op3::SetFinishInterceptionHookPoint(&interceptor_methods_); this->Op4::SetFinishInterceptionHookPoint(&interceptor_methods_); this->Op5::SetFinishInterceptionHookPoint(&interceptor_methods_); this->Op6::SetFinishInterceptionHookPoint(&interceptor_methods_); - interceptor_methods_.SetReverse(); return interceptor_methods_.RunInterceptors(); } diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index f52f9a53be..34c2a477ae 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -299,14 +299,17 @@ class CompletionQueue : private GrpcLibraryCodegen { bool Pluck(internal::CompletionQueueTag* tag) { auto deadline = g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); - auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - bool ok = ev.success != 0; - void* ignored = tag; - GPR_CODEGEN_ASSERT(tag->FinalizeResult(&ignored, &ok)); - GPR_CODEGEN_ASSERT(ignored == tag); - // Ignore mutations by FinalizeResult: Pluck returns the C API status - return ev.success != 0; + while (true) { + auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + bool ok = ev.success != 0; + void* ignored = tag; + if (tag->FinalizeResult(&ignored, &ok)) { + GPR_CODEGEN_ASSERT(ignored == tag); + // Ignore mutations by FinalizeResult: Pluck returns the C API status + return ev.success != 0; + } + } } /// Performs a single polling pluck on \a tag. -- cgit v1.2.3