From 03fffe0fcbe3767fbb3ec301960acd34802fb584 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 31 Mar 2020 13:42:32 -0700 Subject: [PATCH 1/2] Document that AddMultipleHolds argument must be positive --- include/grpcpp/impl/codegen/client_callback_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index 83b183e4a5b..b5adf6b6ea6 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -267,6 +267,7 @@ class ClientBidiReactor { /// StartWritesDone that indicates that there will be no more write ops. /// The number of RemoveHold calls must match the total number of AddHold /// calls plus the number of holds added by AddMultipleHolds. + /// The argument to AddMultipleHolds must be positive. void AddHold() { AddMultipleHolds(1); } void AddMultipleHolds(int holds) { stream_->AddHold(holds); } void RemoveHold() { stream_->RemoveHold(); } From 397b3ee72e4aa578edbd330b672799e6432071d5 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 31 Mar 2020 16:03:44 -0700 Subject: [PATCH 2/2] Do a debug-check of API use --- .../grpcpp/impl/codegen/client_callback_impl.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index b5adf6b6ea6..8e683743e06 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -269,7 +269,10 @@ class ClientBidiReactor { /// calls plus the number of holds added by AddMultipleHolds. /// The argument to AddMultipleHolds must be positive. void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { stream_->AddHold(holds); } + void AddMultipleHolds(int holds) { + GPR_CODEGEN_DEBUG_ASSERT(holds > 0); + stream_->AddHold(holds); + } void RemoveHold() { stream_->RemoveHold(); } /// Notifies the application that all operations associated with this RPC @@ -332,7 +335,10 @@ class ClientReadReactor { void StartRead(Response* resp) { reader_->Read(resp); } void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { reader_->AddHold(holds); } + void AddMultipleHolds(int holds) { + GPR_CODEGEN_DEBUG_ASSERT(holds > 0); + reader_->AddHold(holds); + } void RemoveHold() { reader_->RemoveHold(); } virtual void OnDone(const ::grpc::Status& /*s*/) {} @@ -365,7 +371,10 @@ class ClientWriteReactor { void StartWritesDone() { writer_->WritesDone(); } void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { writer_->AddHold(holds); } + void AddMultipleHolds(int holds) { + GPR_CODEGEN_DEBUG_ASSERT(holds > 0); + writer_->AddHold(holds); + } void RemoveHold() { writer_->RemoveHold(); } virtual void OnDone(const ::grpc::Status& /*s*/) {}