From f50c5a025cb98a313360ebc3ad842970ca8eed85 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 6 Jan 2020 16:33:08 -0800 Subject: [PATCH] Revert "Merge pull request #21494 from grpc/revert-21478-max_message_size" This reverts commit 2e4ebd7478c58d119210b5b68e929e7098282f9c, reversing changes made to 1bd6fcc3388ad35047d7c0b28eb2bff862f276b3. --- include/grpcpp/server_impl.h | 7 ++----- src/cpp/server/server_builder.cc | 29 ++++++++++++++--------------- src/cpp/server/server_cc.cc | 12 ++++++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 5cc7f595d05..9506c419018 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -163,9 +163,6 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// /// Server constructors. To be used by \a ServerBuilder only. /// - /// \param max_message_size Maximum message length that the channel can - /// receive. - /// /// \param args The channel args /// /// \param sync_server_cqs The completion queues to use if the server is a @@ -182,7 +179,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on /// server completion queues passed via sync_server_cqs param. - Server(int max_message_size, ChannelArguments* args, + Server(ChannelArguments* args, std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, @@ -306,7 +303,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { std::unique_ptr> interceptor_creators_; - const int max_receive_message_size_; + int max_receive_message_size_; /// The following completion queues are ONLY used in case of Sync API /// i.e. if the server has any services with sync methods. The server uses diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index c058a75dc03..8acfe536270 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -218,20 +218,9 @@ ServerBuilder& ServerBuilder::AddListeningPort( std::unique_ptr ServerBuilder::BuildAndStart() { grpc::ChannelArguments args; - for (const auto& option : options_) { - option->UpdateArguments(&args); - option->UpdatePlugins(&plugins_); - } - - for (const auto& plugin : plugins_) { - plugin->UpdateServerBuilder(this); - plugin->UpdateChannelArguments(&args); - } - if (max_receive_message_size_ >= -1) { args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, max_receive_message_size_); } - // The default message size is -1 (max), so no need to explicitly set it for // -1. if (max_send_message_size_ >= 0) { @@ -254,6 +243,16 @@ std::unique_ptr ServerBuilder::BuildAndStart() { grpc_resource_quota_arg_vtable()); } + for (const auto& option : options_) { + option->UpdateArguments(&args); + option->UpdatePlugins(&plugins_); + } + + for (const auto& plugin : plugins_) { + plugin->UpdateServerBuilder(this); + plugin->UpdateChannelArguments(&args); + } + // == Determine if the server has any syncrhonous methods == bool has_sync_methods = false; for (const auto& value : services_) { @@ -332,10 +331,10 @@ std::unique_ptr ServerBuilder::BuildAndStart() { } std::unique_ptr server(new grpc::Server( - max_receive_message_size_, &args, sync_server_cqs, - sync_server_settings_.min_pollers, sync_server_settings_.max_pollers, - sync_server_settings_.cq_timeout_msec, std::move(acceptors_), - resource_quota_, std::move(interceptor_creators_))); + &args, sync_server_cqs, sync_server_settings_.min_pollers, + sync_server_settings_.max_pollers, sync_server_settings_.cq_timeout_msec, + std::move(acceptors_), resource_quota_, + std::move(interceptor_creators_))); grpc_impl::ServerInitializer* initializer = server->initializer(); diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index ef4245b0e57..56f189cedaa 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -23,6 +24,7 @@ #include #include +#include #include #include #include @@ -964,7 +966,7 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager { static grpc::internal::GrpcLibraryInitializer g_gli_initializer; Server::Server( - int max_receive_message_size, grpc::ChannelArguments* args, + grpc::ChannelArguments* args, std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, @@ -976,7 +978,7 @@ Server::Server( interceptor_creators) : acceptors_(std::move(acceptors)), interceptor_creators_(std::move(interceptor_creators)), - max_receive_message_size_(max_receive_message_size), + max_receive_message_size_(-1), sync_server_cqs_(std::move(sync_server_cqs)), started_(false), shutdown_(false), @@ -1026,10 +1028,12 @@ Server::Server( static_cast( channel_args.args[i].value.pointer.p)); } - break; + } + if (0 == + strcmp(channel_args.args[i].key, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH)) { + max_receive_message_size_ = channel_args.args[i].value.integer; } } - server_ = grpc_server_create(&channel_args, nullptr); }