diff options
author | yang-g <yangg@google.com> | 2016-06-01 11:21:27 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2016-06-01 11:21:27 -0700 |
commit | 15759f610eb8b9e52bd5a7b24740cd02d3de2f45 (patch) | |
tree | bfda024c8bf1bdf62cb9955e896213b5695aaa91 /include/grpc++ | |
parent | 0d6196025e62aea5aabc6341459f2c370e264230 (diff) |
Let Next set ok=true when receiving error status
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/impl/codegen/async_stream.h | 1 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/async_unary_call.h | 1 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 24 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/sync_stream.h | 1 |
4 files changed, 23 insertions, 4 deletions
diff --git a/include/grpc++/impl/codegen/async_stream.h b/include/grpc++/impl/codegen/async_stream.h index a607a47106..e2954e3a7e 100644 --- a/include/grpc++/impl/codegen/async_stream.h +++ b/include/grpc++/impl/codegen/async_stream.h @@ -172,6 +172,7 @@ class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> { R* response, void* tag) : context_(context), call_(channel->CreateCall(method, context, cq)) { finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); init_ops_.set_output_tag(tag); init_ops_.SendInitialMetadata(context->send_initial_metadata_, diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 55c9788fbd..47ac5bee92 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -91,6 +91,7 @@ class ClientAsyncResponseReader GRPC_FINAL collection_->finish_buf_.RecvInitialMetadata(context_); } collection_->finish_buf_.RecvMessage(msg); + collection_->finish_buf_.AllowNoMessage(); collection_->finish_buf_.ClientRecvStatus(context_, status); call_.PerformOps(&collection_->finish_buf_); } diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index d457f03fa6..4f550b42a2 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -261,10 +261,16 @@ Status CallOpSendMessage::SendMessage(const M& message) { template <class R> class CallOpRecvMessage { public: - CallOpRecvMessage() : got_message(false), message_(nullptr) {} + CallOpRecvMessage() + : got_message(false), + message_(nullptr), + allow_not_getting_message_(false) {} void RecvMessage(R* message) { message_ = message; } + // Do not change status if no message is received. + void AllowNoMessage() { allow_not_getting_message_ = true; } + bool got_message; protected: @@ -290,7 +296,9 @@ class CallOpRecvMessage { } } else { got_message = false; - *status = false; + if (!allow_not_getting_message_) { + *status = false; + } } message_ = nullptr; } @@ -298,6 +306,7 @@ class CallOpRecvMessage { private: R* message_; grpc_byte_buffer* recv_buf_; + bool allow_not_getting_message_; }; namespace CallOpGenericRecvMessageHelper { @@ -325,7 +334,8 @@ class DeserializeFuncType GRPC_FINAL : public DeserializeFunc { class CallOpGenericRecvMessage { public: - CallOpGenericRecvMessage() : got_message(false) {} + CallOpGenericRecvMessage() + : got_message(false), allow_not_getting_message_(false) {} template <class R> void RecvMessage(R* message) { @@ -336,6 +346,9 @@ class CallOpGenericRecvMessage { deserialize_.reset(func); } + // Do not change status if no message is received. + void AllowNoMessage() { allow_not_getting_message_ = true; } + bool got_message; protected: @@ -360,7 +373,9 @@ class CallOpGenericRecvMessage { } } else { got_message = false; - *status = false; + if (!allow_not_getting_message_) { + *status = false; + } } deserialize_.reset(); } @@ -368,6 +383,7 @@ class CallOpGenericRecvMessage { private: std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_; grpc_byte_buffer* recv_buf_; + bool allow_not_getting_message_; }; class CallOpClientSendClose { diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 9100ce09a2..e94ffe5842 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -189,6 +189,7 @@ class ClientWriter : public ClientWriterInterface<W> { ClientContext* context, R* response) : context_(context), call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); CallOpSet<CallOpSendInitialMetadata> ops; ops.SendInitialMetadata(context->send_initial_metadata_, |