diff options
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 73 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/method_handler_impl.h | 4 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/proto_utils.h | 7 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/rpc_service_method.h | 4 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/serialization_traits.h | 8 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/server_interface.h | 6 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/sync_stream.h | 8 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/thrift_utils.h | 2 | ||||
-rw-r--r-- | include/grpc++/server.h | 12 | ||||
-rw-r--r-- | include/grpc++/server_builder.h | 20 | ||||
-rw-r--r-- | include/grpc++/support/byte_buffer.h | 2 |
11 files changed, 84 insertions, 62 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 20087289f8..e211373e7d 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -175,7 +175,7 @@ template <int I> class CallNoOp { protected: void AddOp(grpc_op* ops, size_t* nops) {} - void FinishOp(bool* status, int max_message_size) {} + void FinishOp(bool* status, int max_receive_message_size) {} }; class CallOpSendInitialMetadata { @@ -213,7 +213,7 @@ class CallOpSendInitialMetadata { op->data.send_initial_metadata.maybe_compression_level.level = maybe_compression_level_.level; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (!send_) return; g_core_codegen_interface->gpr_free(initial_metadata_); send_ = false; @@ -253,7 +253,7 @@ class CallOpSendMessage { // Flags are per-message: clear them after use. write_options_.Clear(); } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (own_buf_) g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_); send_buf_ = nullptr; } @@ -301,13 +301,14 @@ class CallOpRecvMessage { op->data.recv_message = &recv_buf_; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (message_ == nullptr) return; if (recv_buf_) { if (*status) { - got_message = *status = SerializationTraits<R>::Deserialize( - recv_buf_, message_, max_message_size) - .ok(); + got_message = *status = + SerializationTraits<R>::Deserialize(recv_buf_, message_, + max_receive_message_size) + .ok(); } else { got_message = false; g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_); @@ -330,7 +331,8 @@ class CallOpRecvMessage { namespace CallOpGenericRecvMessageHelper { class DeserializeFunc { public: - virtual Status Deserialize(grpc_byte_buffer* buf, int max_message_size) = 0; + virtual Status Deserialize(grpc_byte_buffer* buf, + int max_receive_message_size) = 0; virtual ~DeserializeFunc() {} }; @@ -339,8 +341,9 @@ class DeserializeFuncType GRPC_FINAL : public DeserializeFunc { public: DeserializeFuncType(R* message) : message_(message) {} Status Deserialize(grpc_byte_buffer* buf, - int max_message_size) GRPC_OVERRIDE { - return SerializationTraits<R>::Deserialize(buf, message_, max_message_size); + int max_receive_message_size) GRPC_OVERRIDE { + return SerializationTraits<R>::Deserialize(buf, message_, + max_receive_message_size); } ~DeserializeFuncType() GRPC_OVERRIDE {} @@ -379,12 +382,13 @@ class CallOpGenericRecvMessage { op->data.recv_message = &recv_buf_; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (!deserialize_) return; if (recv_buf_) { if (*status) { got_message = true; - *status = deserialize_->Deserialize(recv_buf_, max_message_size).ok(); + *status = + deserialize_->Deserialize(recv_buf_, max_receive_message_size).ok(); } else { got_message = false; g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_); @@ -418,7 +422,7 @@ class CallOpClientSendClose { op->flags = 0; op->reserved = NULL; } - void FinishOp(bool* status, int max_message_size) { send_ = false; } + void FinishOp(bool* status, int max_receive_message_size) { send_ = false; } private: bool send_; @@ -453,7 +457,7 @@ class CallOpServerSendStatus { op->reserved = NULL; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (!send_status_available_) return; g_core_codegen_interface->gpr_free(trailing_metadata_); send_status_available_ = false; @@ -486,7 +490,7 @@ class CallOpRecvInitialMetadata { op->flags = 0; op->reserved = NULL; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (recv_initial_metadata_ == nullptr) return; FillMetadataMap(&recv_initial_metadata_arr_, recv_initial_metadata_); recv_initial_metadata_ = nullptr; @@ -525,7 +529,7 @@ class CallOpClientRecvStatus { op->reserved = NULL; } - void FinishOp(bool* status, int max_message_size) { + void FinishOp(bool* status, int max_receive_message_size) { if (recv_status_ == nullptr) return; FillMetadataMap(&recv_trailing_metadata_arr_, recv_trailing_metadata_); *recv_status_ = Status( @@ -562,13 +566,13 @@ class CallOpSetCollectionInterface /// API. class CallOpSetInterface : public CompletionQueueTag { public: - CallOpSetInterface() : max_message_size_(0) {} + CallOpSetInterface() : max_receive_message_size_(0) {} /// Fills in grpc_op, starting from ops[*nops] and moving /// upwards. virtual void FillOps(grpc_op* ops, size_t* nops) = 0; - void set_max_message_size(int max_message_size) { - max_message_size_ = max_message_size; + void set_max_receive_message_size(int max_receive_message_size) { + max_receive_message_size_ = max_receive_message_size; } /// Mark this as belonging to a collection if needed @@ -577,7 +581,7 @@ class CallOpSetInterface : public CompletionQueueTag { } protected: - int max_message_size_; + int max_receive_message_size_; std::shared_ptr<CallOpSetCollectionInterface> collection_; }; @@ -609,12 +613,12 @@ class CallOpSet : public CallOpSetInterface, } bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { - this->Op1::FinishOp(status, max_message_size_); - this->Op2::FinishOp(status, max_message_size_); - this->Op3::FinishOp(status, max_message_size_); - this->Op4::FinishOp(status, max_message_size_); - this->Op5::FinishOp(status, max_message_size_); - this->Op6::FinishOp(status, max_message_size_); + this->Op1::FinishOp(status, max_receive_message_size_); + this->Op2::FinishOp(status, max_receive_message_size_); + this->Op3::FinishOp(status, max_receive_message_size_); + this->Op4::FinishOp(status, max_receive_message_size_); + this->Op5::FinishOp(status, max_receive_message_size_); + this->Op6::FinishOp(status, max_receive_message_size_); *tag = return_tag_; collection_.reset(); // drop the ref at this point return true; @@ -646,18 +650,21 @@ class Call GRPC_FINAL { public: /* call is owned by the caller */ Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq) - : call_hook_(call_hook), cq_(cq), call_(call), max_message_size_(-1) {} + : call_hook_(call_hook), + cq_(cq), + call_(call), + max_receive_message_size_(-1) {} Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, - int max_message_size) + int max_receive_message_size) : call_hook_(call_hook), cq_(cq), call_(call), - max_message_size_(max_message_size) {} + max_receive_message_size_(max_receive_message_size) {} void PerformOps(CallOpSetInterface* ops) { - if (max_message_size_ > 0) { - ops->set_max_message_size(max_message_size_); + if (max_receive_message_size_ > 0) { + ops->set_max_receive_message_size(max_receive_message_size_); } call_hook_->PerformOpsOnCall(ops, this); } @@ -665,13 +672,13 @@ class Call GRPC_FINAL { grpc_call* call() const { return call_; } CompletionQueue* cq() const { return cq_; } - int max_message_size() const { return max_message_size_; } + int max_receive_message_size() { return max_receive_message_size_; } private: CallHook* call_hook_; CompletionQueue* cq_; grpc_call* call_; - int max_message_size_; + int max_receive_message_size_; }; } // namespace grpc diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index d989263252..52f927631c 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -53,7 +53,7 @@ class RpcMethodHandler : public MethodHandler { void RunHandler(const HandlerParameter& param) GRPC_FINAL { RequestType req; Status status = SerializationTraits<RequestType>::Deserialize( - param.request, &req, param.max_message_size); + param.request, &req, param.max_receive_message_size); ResponseType rsp; if (status.ok()) { status = func_(service_, param.server_context, &req, &rsp); @@ -139,7 +139,7 @@ class ServerStreamingHandler : public MethodHandler { void RunHandler(const HandlerParameter& param) GRPC_FINAL { RequestType req; Status status = SerializationTraits<RequestType>::Deserialize( - param.request, &req, param.max_message_size); + param.request, &req, param.max_receive_message_size); if (status.ok()) { ServerWriter<ResponseType> writer(param.call, param.server_context); diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index d2e0f6fcdd..6f4786b87b 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -204,7 +204,7 @@ class SerializationTraits<T, typename std::enable_if<std::is_base_of< static Status Deserialize(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg, - int max_message_size) { + int max_receive_message_size) { if (buffer == nullptr) { return Status(StatusCode::INTERNAL, "No payload"); } @@ -215,8 +215,9 @@ class SerializationTraits<T, typename std::enable_if<std::is_base_of< return reader.status(); } ::grpc::protobuf::io::CodedInputStream decoder(&reader); - if (max_message_size > 0) { - decoder.SetTotalBytesLimit(max_message_size, max_message_size); + if (max_receive_message_size > 0) { + decoder.SetTotalBytesLimit(max_receive_message_size, + max_receive_message_size); } if (!msg->ParseFromCodedStream(&decoder)) { result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h index 88da0965c8..78c54e3771 100644 --- a/include/grpc++/impl/codegen/rpc_service_method.h +++ b/include/grpc++/impl/codegen/rpc_service_method.h @@ -62,12 +62,12 @@ class MethodHandler { : call(c), server_context(context), request(req), - max_message_size(max_size) {} + max_receive_message_size(max_size) {} Call* call; ServerContext* server_context; // Handler required to grpc_byte_buffer_destroy this grpc_byte_buffer* request; - int max_message_size; + int max_receive_message_size; }; virtual void RunHandler(const HandlerParameter& param) = 0; }; diff --git a/include/grpc++/impl/codegen/serialization_traits.h b/include/grpc++/impl/codegen/serialization_traits.h index fa99dbfa9c..54e5d47632 100644 --- a/include/grpc++/impl/codegen/serialization_traits.h +++ b/include/grpc++/impl/codegen/serialization_traits.h @@ -43,10 +43,10 @@ namespace grpc { /// functions: /// static Status Serialize(const Message& msg, /// grpc_byte_buffer** buffer, -// bool* own_buffer); +/// bool* own_buffer); /// static Status Deserialize(grpc_byte_buffer* buffer, /// Message* msg, -/// int max_message_size); +/// int max_receive_message_size); /// /// Serialize is required to convert message to a grpc_byte_buffer, and /// to store a pointer to that byte buffer at *buffer. *own_buffer should @@ -54,8 +54,8 @@ namespace grpc { /// ownership is retained elsewhere. /// /// Deserialize is required to convert buffer into the message stored at -/// msg. max_message_size is passed in as a bound on the maximum number of -/// message bytes Deserialize should accept. +/// msg. max_receive_message_size is passed in as a bound on the maximum +/// number of message bytes Deserialize should accept. /// /// Both functions return a Status, allowing them to explain what went /// wrong if required. diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h index 1f1b714cbf..4a00d7a3a1 100644 --- a/include/grpc++/impl/codegen/server_interface.h +++ b/include/grpc++/impl/codegen/server_interface.h @@ -134,7 +134,7 @@ class ServerInterface : public CallHook { virtual void ShutdownInternal(gpr_timespec deadline) = 0; - virtual int max_message_size() const = 0; + virtual int max_receive_message_size() const = 0; virtual grpc_server* server() = 0; @@ -205,8 +205,8 @@ class ServerInterface : public CallHook { bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool serialization_status = *status && payload_ && - SerializationTraits<Message>::Deserialize(payload_, request_, - server_->max_message_size()) + SerializationTraits<Message>::Deserialize( + payload_, request_, server_->max_receive_message_size()) .ok(); bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status); *status = serialization_status && *status; diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index aba129811b..e3c5a919b1 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -160,7 +160,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> { } bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { - *sz = call_.max_message_size(); + *sz = call_.max_receive_message_size(); return true; } @@ -310,7 +310,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { } bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { - *sz = call_.max_message_size(); + *sz = call_.max_receive_message_size(); return true; } @@ -382,7 +382,7 @@ class ServerReader GRPC_FINAL : public ServerReaderInterface<R> { } bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { - *sz = call_->max_message_size(); + *sz = call_->max_receive_message_size(); return true; } @@ -474,7 +474,7 @@ class ServerReaderWriterBody GRPC_FINAL { } bool NextMessageSize(uint32_t* sz) { - *sz = call_->max_message_size(); + *sz = call_->max_receive_message_size(); return true; } diff --git a/include/grpc++/impl/codegen/thrift_utils.h b/include/grpc++/impl/codegen/thrift_utils.h index be558c5789..742d739703 100644 --- a/include/grpc++/impl/codegen/thrift_utils.h +++ b/include/grpc++/impl/codegen/thrift_utils.h @@ -64,7 +64,7 @@ class SerializationTraits<T, typename std::enable_if<std::is_base_of< } static Status Deserialize(grpc_byte_buffer* buffer, T* msg, - int max_message_size) { + int max_receive_message_size) { if (!buffer) { return Status(StatusCode::INTERNAL, "No payload"); } diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 6876961e21..6e15035125 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -116,10 +116,10 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen { /// /// \param thread_pool The threadpool instance to use for call processing. /// \param thread_pool_owned Does the server own the \a thread_pool instance? - /// \param max_message_size Maximum message length that the channel can - /// receive. + /// \param max_receive_message_size Maximum message length that the channel + /// can receive. Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, - int max_message_size, ChannelArguments* args); + int max_receive_message_size, ChannelArguments* args); /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the Server instance. @@ -164,13 +164,15 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen { void ShutdownInternal(gpr_timespec deadline) GRPC_OVERRIDE; - int max_message_size() const GRPC_OVERRIDE { return max_message_size_; }; + int max_receive_message_size() const GRPC_OVERRIDE { + return max_receive_message_size_; + }; grpc_server* server() GRPC_OVERRIDE { return server_; }; ServerInitializer* initializer(); - const int max_message_size_; + const int max_receive_message_size_; // Completion queue. CompletionQueue cq_; diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index b9c49f0b19..37f1f8cb80 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -78,12 +78,23 @@ class ServerBuilder { /// Only matches requests with :authority \a host ServerBuilder& RegisterService(const grpc::string& host, Service* service); - /// Set max message size in bytes. - ServerBuilder& SetMaxMessageSize(int max_message_size) { - max_message_size_ = max_message_size; + /// Set max receive message size in bytes. + ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) { + max_receive_message_size_ = max_receive_message_size; + return *this; + } + + /// Set max send message size in bytes. + ServerBuilder& SetMaxSendMessageSize(int max_send_message_size) { + max_send_message_size_ = max_send_message_size; return *this; } + /// \deprecated For backward compatibility. + ServerBuilder& SetMaxMessageSize(int max_message_size) { + return SetMaxReceiveMessageSize(max_message_size); + } + /// Set the support status for compression algorithms. All algorithms are /// enabled by default. /// @@ -168,7 +179,8 @@ class ServerBuilder { Service* service; }; - int max_message_size_; + int max_receive_message_size_; + int max_send_message_size_; std::vector<std::unique_ptr<ServerBuilderOption>> options_; std::vector<std::unique_ptr<NamedService>> services_; std::vector<Port> ports_; diff --git a/include/grpc++/support/byte_buffer.h b/include/grpc++/support/byte_buffer.h index 01249a0b88..06f8969b70 100644 --- a/include/grpc++/support/byte_buffer.h +++ b/include/grpc++/support/byte_buffer.h @@ -96,7 +96,7 @@ template <> class SerializationTraits<ByteBuffer, void> { public: static Status Deserialize(grpc_byte_buffer* byte_buffer, ByteBuffer* dest, - int max_message_size) { + int max_receive_message_size) { dest->set_buffer(byte_buffer); return Status::OK; } |