Merge pull request #14883 from ara-ayvazyan/fix_serverinterface_bytebuffer

Fix ServerInterface::PayloadAsyncRequest to work with ByteBuffer
pull/14904/head
Noah Eisen 7 years ago committed by GitHub
commit 0b49467404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      include/grpcpp/impl/codegen/byte_buffer.h
  2. 13
      include/grpcpp/impl/codegen/server_interface.h

@ -31,6 +31,8 @@
namespace grpc { namespace grpc {
class ServerInterface;
namespace internal { namespace internal {
class CallOpSendMessage; class CallOpSendMessage;
template <class R> template <class R>
@ -98,6 +100,7 @@ class ByteBuffer final {
private: private:
friend class SerializationTraits<ByteBuffer, void>; friend class SerializationTraits<ByteBuffer, void>;
friend class ServerInterface;
friend class internal::CallOpSendMessage; friend class internal::CallOpSendMessage;
template <class R> template <class R>
friend class internal::CallOpRecvMessage; friend class internal::CallOpRecvMessage;

@ -20,6 +20,7 @@
#define GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H #define GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
#include <grpcpp/impl/codegen/call_hook.h> #include <grpcpp/impl/codegen/call_hook.h>
#include <grpcpp/impl/codegen/completion_queue_tag.h> #include <grpcpp/impl/codegen/completion_queue_tag.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/core_codegen_interface.h>
@ -185,13 +186,17 @@ class ServerInterface : public internal::CallHook {
notification_cq_(notification_cq), notification_cq_(notification_cq),
tag_(tag), tag_(tag),
request_(request) { request_(request) {
IssueRequest(registered_method, &payload_, notification_cq); IssueRequest(registered_method, payload_.bbuf_ptr(), notification_cq);
}
~PayloadAsyncRequest() {
payload_.Release(); // We do not own the payload_
} }
bool FinalizeResult(void** tag, bool* status) override { bool FinalizeResult(void** tag, bool* status) override {
if (*status) { if (*status) {
if (payload_ == nullptr || if (!payload_.Valid() || !SerializationTraits<Message>::Deserialize(
!SerializationTraits<Message>::Deserialize(payload_, request_) payload_.bbuf_ptr(), request_)
.ok()) { .ok()) {
// If deserialization fails, we cancel the call and instantiate // If deserialization fails, we cancel the call and instantiate
// a new instance of ourselves to request another call. We then // a new instance of ourselves to request another call. We then
@ -219,7 +224,7 @@ class ServerInterface : public internal::CallHook {
ServerCompletionQueue* const notification_cq_; ServerCompletionQueue* const notification_cq_;
void* const tag_; void* const tag_;
Message* const request_; Message* const request_;
grpc_byte_buffer* payload_; ByteBuffer payload_;
}; };
class GenericAsyncRequest : public BaseAsyncRequest { class GenericAsyncRequest : public BaseAsyncRequest {

Loading…
Cancel
Save