Skip to content

Commit

Permalink
Revert "Merge pull request grpc#21494 from grpc/revert-21478-max_mess…
Browse files Browse the repository at this point in the history
…age_size"

This reverts commit 2e4ebd7, reversing
changes made to 1bd6fcc.
  • Loading branch information
yang-g committed Jan 7, 2020
1 parent a29b3b7 commit f50c5a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
7 changes: 2 additions & 5 deletions include/grpcpp/server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<std::vector<std::unique_ptr<ServerCompletionQueue>>>
sync_server_cqs,
int min_pollers, int max_pollers, int sync_cq_timeout_msec,
Expand Down Expand Up @@ -306,7 +303,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen {
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>
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
Expand Down
29 changes: 14 additions & 15 deletions src/cpp/server/server_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,9 @@ ServerBuilder& ServerBuilder::AddListeningPort(

std::unique_ptr<grpc::Server> 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) {
Expand All @@ -254,6 +243,16 @@ std::unique_ptr<grpc::Server> 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_) {
Expand Down Expand Up @@ -332,10 +331,10 @@ std::unique_ptr<grpc::Server> ServerBuilder::BuildAndStart() {
}

std::unique_ptr<grpc::Server> 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();

Expand Down
12 changes: 8 additions & 4 deletions src/cpp/server/server_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <grpc/impl/codegen/grpc_types.h>
#include <grpcpp/server.h>

#include <cstdlib>
Expand All @@ -23,6 +24,7 @@
#include <utility>

#include <grpc/grpc.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/completion_queue.h>
Expand Down Expand Up @@ -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<std::vector<std::unique_ptr<grpc::ServerCompletionQueue>>>
sync_server_cqs,
int min_pollers, int max_pollers, int sync_cq_timeout_msec,
Expand All @@ -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),
Expand Down Expand Up @@ -1026,10 +1028,12 @@ Server::Server(
static_cast<grpc::HealthCheckServiceInterface*>(
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);
}

Expand Down

0 comments on commit f50c5a0

Please sign in to comment.