diff options
author | ncteisen <ncteisen@gmail.com> | 2017-06-26 17:00:10 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-07-05 10:33:21 -0700 |
commit | 43f2b55a079660414b47d2de393ccd374be79fd2 (patch) | |
tree | c962381d7fab00a1f3cd2ff3956834e5dfc1d8dc /include/grpc++/impl/codegen | |
parent | 95f7a517464f62a61684a45879697ad22e3aea82 (diff) |
Add repro and fix to bidi case
Diffstat (limited to 'include/grpc++/impl/codegen')
-rw-r--r-- | include/grpc++/impl/codegen/method_handler_impl.h | 3 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/sync_stream.h | 20 |
2 files changed, 16 insertions, 7 deletions
diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 5afa4e9f7e..6ec2836037 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -188,6 +188,9 @@ class TemplatedBidiStreamingHandler : public MethodHandler { } ops.ServerSendStatus(param.server_context->trailing_metadata_, status); param.call->PerformOps(&ops); + if (param.server_context->has_hanging_ops_) { + param.call->cq()->Pluck(¶m.server_context->hanging_ops_); + } param.call->cq()->Pluck(&ops); } diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index b7d81b3382..677fa78d9e 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -661,20 +661,26 @@ class ServerReaderWriterBody final { if (options.is_last_message()) { options.set_buffer_hint(); } - CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> ops; - if (!ops.SendMessage(msg, options).ok()) { + if (!ctx_->hanging_ops_.SendMessage(msg, options).ok()) { return false; } if (!ctx_->sent_initial_metadata_) { - ops.SendInitialMetadata(ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); + ctx_->hanging_ops_.SendInitialMetadata(ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); + ctx_->hanging_ops_.set_compression_level(ctx_->compression_level()); } ctx_->sent_initial_metadata_ = true; } - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops); + call_->PerformOps(&ctx_->hanging_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_hanging_ops_ = true; + return true; + } + return call_->cq()->Pluck(&ctx_->hanging_ops_); } private: |