aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2016-09-26 16:11:02 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2016-09-26 16:11:02 -0700
commit2d08f5bc8d8938445bf3b03d2da897898c4096d0 (patch)
tree76c4672813ec676d87c050191323eb4bda3c8c86 /src/cpp
parent862acb9f3a42cf4bacf75ba9dd831a539c93a4f1 (diff)
fix the plugin initialization order in ServerBuilder
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/server/server_builder.cc59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index e28ba5af11..eab57b4ac3 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -140,6 +140,35 @@ ServerBuilder& ServerBuilder::AddListeningPort(
}
std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
+ ChannelArguments args;
+ for (auto option = options_.begin(); option != options_.end(); ++option) {
+ (*option)->UpdateArguments(&args);
+ (*option)->UpdatePlugins(&plugins_);
+ }
+
+ for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
+ (*plugin)->UpdateChannelArguments(&args);
+ }
+
+ if (max_receive_message_size_ >= 0) {
+ args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, max_receive_message_size_);
+ }
+
+ if (max_send_message_size_ >= 0) {
+ args.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, max_send_message_size_);
+ }
+
+ args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
+ enabled_compression_algorithms_bitset_);
+ if (maybe_default_compression_level_.is_set) {
+ args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL,
+ maybe_default_compression_level_.level);
+ }
+ if (maybe_default_compression_algorithm_.is_set) {
+ args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
+ maybe_default_compression_algorithm_.algorithm);
+ }
+
// == Determine if the server has any syncrhonous methods ==
bool has_sync_methods = false;
for (auto it = services_.begin(); it != services_.end(); ++it) {
@@ -184,36 +213,6 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
}
}
- // == Channel args ==
- ChannelArguments args;
- for (auto option = options_.begin(); option != options_.end(); ++option) {
- (*option)->UpdateArguments(&args);
- (*option)->UpdatePlugins(&plugins_);
- }
-
- for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
- (*plugin)->UpdateChannelArguments(&args);
- }
-
- if (max_receive_message_size_ >= 0) {
- args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, max_receive_message_size_);
- }
-
- if (max_send_message_size_ >= 0) {
- args.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, max_send_message_size_);
- }
-
- args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
- enabled_compression_algorithms_bitset_);
- if (maybe_default_compression_level_.is_set) {
- args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL,
- maybe_default_compression_level_.level);
- }
- if (maybe_default_compression_algorithm_.is_set) {
- args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
- maybe_default_compression_algorithm_.algorithm);
- }
-
// TODO (sreek) Make the number of pollers configurable
std::unique_ptr<Server> server(
new Server(sync_server_cqs, max_receive_message_size_, &args,