From a23f17b1233453334ad137a3aeb338c801b5ada4 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 25 Nov 2015 10:21:05 -0800 Subject: add server_builder_option --- include/grpc++/impl/server_builder_option.h | 49 +++++++++++++++++++++++++++++ include/grpc++/server.h | 5 +-- include/grpc++/server_builder.h | 6 +++- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 include/grpc++/impl/server_builder_option.h (limited to 'include/grpc++') diff --git a/include/grpc++/impl/server_builder_option.h b/include/grpc++/impl/server_builder_option.h new file mode 100644 index 0000000000..cf5c1d93e4 --- /dev/null +++ b/include/grpc++/impl/server_builder_option.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_SERVER_BUILDER_OPTION_H +#define GRPCXX_IMPL_SERVER_BUILDER_OPTION_H + +#include + +namespace grpc { + +class ServerBuilderOption { + public: + virtual ~ServerBuilderOption() {} + virtual void UpdateArguments(ChannelArguments* args) = 0; +}; + +} // namespace grpc + +#endif // GRPCXX_IMPL_SERVER_BUILDER_OPTION_H diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 1a62df5698..3161526aa9 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -37,14 +37,15 @@ #include #include -#include #include #include #include #include #include +#include #include #include +#include struct grpc_server; @@ -100,7 +101,7 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { /// \param max_message_size Maximum message length that the channel can /// receive. Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, - int max_message_size, grpc_compression_options compression_options); + int max_message_size, const 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. diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 05937f150b..b324deb9e0 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -37,8 +37,9 @@ #include #include -#include +#include #include +#include namespace grpc { @@ -98,6 +99,8 @@ class ServerBuilder { compression_options_ = options; } + void SetOption(std::unique_ptr option); + /// Tries to bind \a server to the given \a addr. /// /// It can be invoked multiple times. @@ -140,6 +143,7 @@ class ServerBuilder { int max_message_size_; grpc_compression_options compression_options_; + std::vector> options_; std::vector>> services_; std::vector>> async_services_; -- cgit v1.2.3 From 52705590e463df5e6b852f15866cdfbfcf902fcb Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 25 Nov 2015 11:45:33 -0800 Subject: Add set pointer api to channel_arguments --- BUILD | 6 +- Makefile | 12 +- build.yaml | 6 +- include/grpc++/support/channel_arguments.h | 5 + src/cpp/client/channel_arguments.cc | 111 ---------------- src/cpp/client/secure_channel_arguments.cc | 54 -------- src/cpp/common/channel_arguments.cc | 124 ++++++++++++++++++ src/cpp/common/secure_channel_arguments.cc | 54 ++++++++ test/cpp/client/channel_arguments_test.cc | 124 ------------------ test/cpp/common/channel_arguments_test.cc | 140 +++++++++++++++++++++ tools/doxygen/Doxyfile.c++.internal | 4 +- tools/run_tests/sources_and_headers.json | 8 +- vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj | 4 +- .../grpc++_unsecure.vcxproj.filters | 6 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 8 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 12 +- .../grpc++_unsecure/grpc++_unsecure.vcxproj | 4 +- .../grpc++_unsecure.vcxproj.filters | 6 +- .../channel_arguments_test.vcxproj | 2 +- .../channel_arguments_test.vcxproj.filters | 8 +- 20 files changed, 366 insertions(+), 332 deletions(-) delete mode 100644 src/cpp/client/channel_arguments.cc delete mode 100644 src/cpp/client/secure_channel_arguments.cc create mode 100644 src/cpp/common/channel_arguments.cc create mode 100644 src/cpp/common/secure_channel_arguments.cc delete mode 100644 test/cpp/client/channel_arguments_test.cc create mode 100644 test/cpp/common/channel_arguments_test.cc (limited to 'include/grpc++') diff --git a/BUILD b/BUILD index 5ae3b37b29..607eb8f86a 100644 --- a/BUILD +++ b/BUILD @@ -736,14 +736,13 @@ cc_library( "src/cpp/server/dynamic_thread_pool.h", "src/cpp/server/fixed_size_thread_pool.h", "src/cpp/server/thread_pool_interface.h", - "src/cpp/client/secure_channel_arguments.cc", "src/cpp/client/secure_credentials.cc", "src/cpp/common/auth_property_iterator.cc", "src/cpp/common/secure_auth_context.cc", + "src/cpp/common/secure_channel_arguments.cc", "src/cpp/common/secure_create_auth_context.cc", "src/cpp/server/secure_server_credentials.cc", "src/cpp/client/channel.cc", - "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", @@ -751,6 +750,7 @@ cc_library( "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/call.cc", + "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", @@ -836,7 +836,6 @@ cc_library( "src/cpp/server/thread_pool_interface.h", "src/cpp/common/insecure_create_auth_context.cc", "src/cpp/client/channel.cc", - "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", @@ -844,6 +843,7 @@ cc_library( "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/call.cc", + "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", diff --git a/Makefile b/Makefile index e239aab999..8e3082e8d5 100644 --- a/Makefile +++ b/Makefile @@ -5053,14 +5053,13 @@ endif LIBGRPC++_SRC = \ - src/cpp/client/secure_channel_arguments.cc \ src/cpp/client/secure_credentials.cc \ src/cpp/common/auth_property_iterator.cc \ src/cpp/common/secure_auth_context.cc \ + src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ src/cpp/server/secure_server_credentials.cc \ src/cpp/client/channel.cc \ - src/cpp/client/channel_arguments.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ @@ -5068,6 +5067,7 @@ LIBGRPC++_SRC = \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/call.cc \ + src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ @@ -5307,7 +5307,6 @@ $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/test/cpp/util/messages LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/insecure_create_auth_context.cc \ src/cpp/client/channel.cc \ - src/cpp/client/channel_arguments.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ @@ -5315,6 +5314,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/call.cc \ + src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ @@ -9587,7 +9587,7 @@ endif CHANNEL_ARGUMENTS_TEST_SRC = \ - test/cpp/client/channel_arguments_test.cc \ + test/cpp/common/channel_arguments_test.cc \ CHANNEL_ARGUMENTS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_ARGUMENTS_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -9616,7 +9616,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/client/channel_arguments_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/common/channel_arguments_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_channel_arguments_test: $(CHANNEL_ARGUMENTS_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -23152,10 +23152,10 @@ src/core/surface/secure_channel_create.c: $(OPENSSL_DEP) src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP) src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP) src/core/tsi/transport_security.c: $(OPENSSL_DEP) -src/cpp/client/secure_channel_arguments.cc: $(OPENSSL_DEP) src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP) src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP) src/cpp/common/secure_auth_context.cc: $(OPENSSL_DEP) +src/cpp/common/secure_channel_arguments.cc: $(OPENSSL_DEP) src/cpp/common/secure_create_auth_context.cc: $(OPENSSL_DEP) src/cpp/server/secure_server_credentials.cc: $(OPENSSL_DEP) src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 612983596b..99d0582a69 100644 --- a/build.yaml +++ b/build.yaml @@ -73,7 +73,6 @@ filegroups: - src/cpp/server/thread_pool_interface.h src: - src/cpp/client/channel.cc - - src/cpp/client/channel_arguments.cc - src/cpp/client/client_context.cc - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc @@ -81,6 +80,7 @@ filegroups: - src/cpp/client/generic_stub.cc - src/cpp/client/insecure_credentials.cc - src/cpp/common/call.cc + - src/cpp/common/channel_arguments.cc - src/cpp/common/completion_queue.cc - src/cpp/common/rpc_method.cc - src/cpp/proto/proto_utils.cc @@ -594,10 +594,10 @@ libs: - src/cpp/common/secure_auth_context.h - src/cpp/server/secure_server_credentials.h src: - - src/cpp/client/secure_channel_arguments.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/auth_property_iterator.cc - src/cpp/common/secure_auth_context.cc + - src/cpp/common/secure_channel_arguments.cc - src/cpp/common/secure_create_auth_context.cc - src/cpp/server/secure_server_credentials.cc deps: @@ -1663,7 +1663,7 @@ targets: build: test language: c++ src: - - test/cpp/client/channel_arguments_test.cc + - test/cpp/common/channel_arguments_test.cc deps: - grpc++ - grpc diff --git a/include/grpc++/support/channel_arguments.h b/include/grpc++/support/channel_arguments.h index cf8eab3b47..a2960a7ecc 100644 --- a/include/grpc++/support/channel_arguments.h +++ b/include/grpc++/support/channel_arguments.h @@ -80,6 +80,11 @@ class ChannelArguments { // Generic channel argument setters. Only for advanced use cases. /// Set an integer argument \a value under \a key. void SetInt(const grpc::string& key, int value); + + // Generic channel argument setter. Only for advanced use cases. + /// Set a pointer argument \a value under \a key. Owership is not transferred. + void SetPointer(const grpc::string& key, void* value); + /// Set a textual argument \a value under \a key. void SetString(const grpc::string& key, const grpc::string& value); diff --git a/src/cpp/client/channel_arguments.cc b/src/cpp/client/channel_arguments.cc deleted file mode 100644 index 50422d06c9..0000000000 --- a/src/cpp/client/channel_arguments.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include -#include "src/core/channel/channel_args.h" - -namespace grpc { - -ChannelArguments::ChannelArguments(const ChannelArguments& other) - : strings_(other.strings_) { - args_.reserve(other.args_.size()); - auto list_it_dst = strings_.begin(); - auto list_it_src = other.strings_.begin(); - for (auto a = other.args_.begin(); a != other.args_.end(); ++a) { - grpc_arg ap; - ap.type = a->type; - GPR_ASSERT(list_it_src->c_str() == a->key); - ap.key = const_cast(list_it_dst->c_str()); - ++list_it_src; - ++list_it_dst; - switch (a->type) { - case GRPC_ARG_INTEGER: - ap.value.integer = a->value.integer; - break; - case GRPC_ARG_STRING: - GPR_ASSERT(list_it_src->c_str() == a->value.string); - ap.value.string = const_cast(list_it_dst->c_str()); - ++list_it_src; - ++list_it_dst; - break; - case GRPC_ARG_POINTER: - ap.value.pointer = a->value.pointer; - ap.value.pointer.p = a->value.pointer.copy(ap.value.pointer.p); - break; - } - args_.push_back(ap); - } -} - -void ChannelArguments::Swap(ChannelArguments& other) { - args_.swap(other.args_); - strings_.swap(other.strings_); -} - -void ChannelArguments::SetCompressionAlgorithm( - grpc_compression_algorithm algorithm) { - SetInt(GRPC_COMPRESSION_ALGORITHM_ARG, algorithm); -} - -void ChannelArguments::SetInt(const grpc::string& key, int value) { - grpc_arg arg; - arg.type = GRPC_ARG_INTEGER; - strings_.push_back(key); - arg.key = const_cast(strings_.back().c_str()); - arg.value.integer = value; - - args_.push_back(arg); -} - -void ChannelArguments::SetString(const grpc::string& key, - const grpc::string& value) { - grpc_arg arg; - arg.type = GRPC_ARG_STRING; - strings_.push_back(key); - arg.key = const_cast(strings_.back().c_str()); - strings_.push_back(value); - arg.value.string = const_cast(strings_.back().c_str()); - - args_.push_back(arg); -} - -void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { - channel_args->num_args = args_.size(); - if (channel_args->num_args > 0) { - channel_args->args = const_cast(&args_[0]); - } -} - -} // namespace grpc diff --git a/src/cpp/client/secure_channel_arguments.cc b/src/cpp/client/secure_channel_arguments.cc deleted file mode 100644 index e17d3b58b0..0000000000 --- a/src/cpp/client/secure_channel_arguments.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include -#include "src/core/channel/channel_args.h" - -namespace grpc { - -void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) { - SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name); -} - -grpc::string ChannelArguments::GetSslTargetNameOverride() const { - for (unsigned int i = 0; i < args_.size(); i++) { - if (grpc::string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == args_[i].key) { - return args_[i].value.string; - } - } - return ""; -} - -} // namespace grpc diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc new file mode 100644 index 0000000000..90cd5136af --- /dev/null +++ b/src/cpp/common/channel_arguments.cc @@ -0,0 +1,124 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include "src/core/channel/channel_args.h" + +namespace grpc { + +ChannelArguments::ChannelArguments(const ChannelArguments& other) + : strings_(other.strings_) { + args_.reserve(other.args_.size()); + auto list_it_dst = strings_.begin(); + auto list_it_src = other.strings_.begin(); + for (auto a = other.args_.begin(); a != other.args_.end(); ++a) { + grpc_arg ap; + ap.type = a->type; + GPR_ASSERT(list_it_src->c_str() == a->key); + ap.key = const_cast(list_it_dst->c_str()); + ++list_it_src; + ++list_it_dst; + switch (a->type) { + case GRPC_ARG_INTEGER: + ap.value.integer = a->value.integer; + break; + case GRPC_ARG_STRING: + GPR_ASSERT(list_it_src->c_str() == a->value.string); + ap.value.string = const_cast(list_it_dst->c_str()); + ++list_it_src; + ++list_it_dst; + break; + case GRPC_ARG_POINTER: + ap.value.pointer = a->value.pointer; + ap.value.pointer.p = a->value.pointer.copy + ? a->value.pointer.copy(ap.value.pointer.p) + : ap.value.pointer.p; + break; + } + args_.push_back(ap); + } +} + +void ChannelArguments::Swap(ChannelArguments& other) { + args_.swap(other.args_); + strings_.swap(other.strings_); +} + +void ChannelArguments::SetCompressionAlgorithm( + grpc_compression_algorithm algorithm) { + SetInt(GRPC_COMPRESSION_ALGORITHM_ARG, algorithm); +} + +void ChannelArguments::SetInt(const grpc::string& key, int value) { + grpc_arg arg; + arg.type = GRPC_ARG_INTEGER; + strings_.push_back(key); + arg.key = const_cast(strings_.back().c_str()); + arg.value.integer = value; + + args_.push_back(arg); +} + +void ChannelArguments::SetPointer(const grpc::string& key, void* value) { + grpc_arg arg; + arg.type = GRPC_ARG_POINTER; + strings_.push_back(key); + arg.key = const_cast(strings_.back().c_str()); + arg.value.pointer.p = value; + arg.value.pointer.copy = nullptr; + arg.value.pointer.destroy = nullptr; + args_.push_back(arg); +} + +void ChannelArguments::SetString(const grpc::string& key, + const grpc::string& value) { + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + strings_.push_back(key); + arg.key = const_cast(strings_.back().c_str()); + strings_.push_back(value); + arg.value.string = const_cast(strings_.back().c_str()); + + args_.push_back(arg); +} + +void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { + channel_args->num_args = args_.size(); + if (channel_args->num_args > 0) { + channel_args->args = const_cast(&args_[0]); + } +} + +} // namespace grpc diff --git a/src/cpp/common/secure_channel_arguments.cc b/src/cpp/common/secure_channel_arguments.cc new file mode 100644 index 0000000000..e17d3b58b0 --- /dev/null +++ b/src/cpp/common/secure_channel_arguments.cc @@ -0,0 +1,54 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include "src/core/channel/channel_args.h" + +namespace grpc { + +void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) { + SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name); +} + +grpc::string ChannelArguments::GetSslTargetNameOverride() const { + for (unsigned int i = 0; i < args_.size(); i++) { + if (grpc::string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == args_[i].key) { + return args_[i].value.string; + } + } + return ""; +} + +} // namespace grpc diff --git a/test/cpp/client/channel_arguments_test.cc b/test/cpp/client/channel_arguments_test.cc deleted file mode 100644 index 3d75e7b0e6..0000000000 --- a/test/cpp/client/channel_arguments_test.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include -#include - -namespace grpc { -namespace testing { - -class ChannelArgumentsTest : public ::testing::Test { - protected: - void SetChannelArgs(const ChannelArguments& channel_args, - grpc_channel_args* args) { - channel_args.SetChannelArgs(args); - } -}; - -TEST_F(ChannelArgumentsTest, SetInt) { - grpc_channel_args args; - ChannelArguments channel_args; - // Empty arguments. - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(0), args.num_args); - - grpc::string key("key0"); - channel_args.SetInt(key, 0); - // Clear key early to make sure channel_args takes a copy - key = ""; - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(1), args.num_args); - EXPECT_EQ(GRPC_ARG_INTEGER, args.args[0].type); - EXPECT_STREQ("key0", args.args[0].key); - EXPECT_EQ(0, args.args[0].value.integer); - - key = "key1"; - channel_args.SetInt(key, 1); - key = ""; - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(2), args.num_args); - // We do not enforce order on the arguments. - for (size_t i = 0; i < args.num_args; i++) { - EXPECT_EQ(GRPC_ARG_INTEGER, args.args[i].type); - if (grpc::string(args.args[i].key) == "key0") { - EXPECT_EQ(0, args.args[i].value.integer); - } else if (grpc::string(args.args[i].key) == "key1") { - EXPECT_EQ(1, args.args[i].value.integer); - } - } -} - -TEST_F(ChannelArgumentsTest, SetString) { - grpc_channel_args args; - ChannelArguments channel_args; - // Empty arguments. - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(0), args.num_args); - - grpc::string key("key0"); - grpc::string val("val0"); - channel_args.SetString(key, val); - // Clear key/val early to make sure channel_args takes a copy - key = ""; - val = ""; - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(1), args.num_args); - EXPECT_EQ(GRPC_ARG_STRING, args.args[0].type); - EXPECT_STREQ("key0", args.args[0].key); - EXPECT_STREQ("val0", args.args[0].value.string); - - key = "key1"; - val = "val1"; - channel_args.SetString(key, val); - SetChannelArgs(channel_args, &args); - EXPECT_EQ(static_cast(2), args.num_args); - // We do not enforce order on the arguments. - for (size_t i = 0; i < args.num_args; i++) { - EXPECT_EQ(GRPC_ARG_STRING, args.args[i].type); - if (grpc::string(args.args[i].key) == "key0") { - EXPECT_STREQ("val0", args.args[i].value.string); - } else if (grpc::string(args.args[i].key) == "key1") { - EXPECT_STREQ("val1", args.args[i].value.string); - } - } -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc new file mode 100644 index 0000000000..e010d375cf --- /dev/null +++ b/test/cpp/common/channel_arguments_test.cc @@ -0,0 +1,140 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include + +namespace grpc { +namespace testing { + +class ChannelArgumentsTest : public ::testing::Test { + protected: + void SetChannelArgs(const ChannelArguments& channel_args, + grpc_channel_args* args) { + channel_args.SetChannelArgs(args); + } +}; + +TEST_F(ChannelArgumentsTest, SetInt) { + grpc_channel_args args; + ChannelArguments channel_args; + // Empty arguments. + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(0), args.num_args); + + grpc::string key("key0"); + channel_args.SetInt(key, 0); + // Clear key early to make sure channel_args takes a copy + key = ""; + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(1), args.num_args); + EXPECT_EQ(GRPC_ARG_INTEGER, args.args[0].type); + EXPECT_STREQ("key0", args.args[0].key); + EXPECT_EQ(0, args.args[0].value.integer); + + key = "key1"; + channel_args.SetInt(key, 1); + key = ""; + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(2), args.num_args); + // We do not enforce order on the arguments. + for (size_t i = 0; i < args.num_args; i++) { + EXPECT_EQ(GRPC_ARG_INTEGER, args.args[i].type); + if (grpc::string(args.args[i].key) == "key0") { + EXPECT_EQ(0, args.args[i].value.integer); + } else if (grpc::string(args.args[i].key) == "key1") { + EXPECT_EQ(1, args.args[i].value.integer); + } + } +} + +TEST_F(ChannelArgumentsTest, SetString) { + grpc_channel_args args; + ChannelArguments channel_args; + // Empty arguments. + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(0), args.num_args); + + grpc::string key("key0"); + grpc::string val("val0"); + channel_args.SetString(key, val); + // Clear key/val early to make sure channel_args takes a copy + key = ""; + val = ""; + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(1), args.num_args); + EXPECT_EQ(GRPC_ARG_STRING, args.args[0].type); + EXPECT_STREQ("key0", args.args[0].key); + EXPECT_STREQ("val0", args.args[0].value.string); + + key = "key1"; + val = "val1"; + channel_args.SetString(key, val); + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(2), args.num_args); + // We do not enforce order on the arguments. + for (size_t i = 0; i < args.num_args; i++) { + EXPECT_EQ(GRPC_ARG_STRING, args.args[i].type); + if (grpc::string(args.args[i].key) == "key0") { + EXPECT_STREQ("val0", args.args[i].value.string); + } else if (grpc::string(args.args[i].key) == "key1") { + EXPECT_STREQ("val1", args.args[i].value.string); + } + } +} + +TEST_F(ChannelArgumentsTest, SetPointer) { + grpc_channel_args args; + ChannelArguments channel_args; + // Empty arguments. + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(0), args.num_args); + + grpc::string key("key0"); + channel_args.SetPointer(key, &key); + SetChannelArgs(channel_args, &args); + EXPECT_EQ(static_cast(1), args.num_args); + EXPECT_EQ(GRPC_ARG_POINTER, args.args[0].type); + EXPECT_STREQ("key0", args.args[0].key); + EXPECT_EQ(&key, args.args[0].value.pointer.p); +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 26e808c799..ba1dec0d38 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -810,14 +810,13 @@ src/cpp/common/create_auth_context.h \ src/cpp/server/dynamic_thread_pool.h \ src/cpp/server/fixed_size_thread_pool.h \ src/cpp/server/thread_pool_interface.h \ -src/cpp/client/secure_channel_arguments.cc \ src/cpp/client/secure_credentials.cc \ src/cpp/common/auth_property_iterator.cc \ src/cpp/common/secure_auth_context.cc \ +src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ src/cpp/server/secure_server_credentials.cc \ src/cpp/client/channel.cc \ -src/cpp/client/channel_arguments.cc \ src/cpp/client/client_context.cc \ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ @@ -825,6 +824,7 @@ src/cpp/client/credentials.cc \ src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/common/call.cc \ +src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 33b6ccf1f1..1764ce6d74 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -1138,7 +1138,7 @@ "language": "c++", "name": "channel_arguments_test", "src": [ - "test/cpp/client/channel_arguments_test.cc" + "test/cpp/common/channel_arguments_test.cc" ] }, { @@ -15353,7 +15353,6 @@ "include/grpc++/support/sync_stream.h", "include/grpc++/support/time.h", "src/cpp/client/channel.cc", - "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", @@ -15361,16 +15360,17 @@ "src/cpp/client/credentials.cc", "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", - "src/cpp/client/secure_channel_arguments.cc", "src/cpp/client/secure_credentials.cc", "src/cpp/client/secure_credentials.h", "src/cpp/common/auth_property_iterator.cc", "src/cpp/common/call.cc", + "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/create_auth_context.h", "src/cpp/common/rpc_method.cc", "src/cpp/common/secure_auth_context.cc", "src/cpp/common/secure_auth_context.h", + "src/cpp/common/secure_channel_arguments.cc", "src/cpp/common/secure_create_auth_context.cc", "src/cpp/proto/proto_utils.cc", "src/cpp/server/async_generic_service.cc", @@ -15536,7 +15536,6 @@ "include/grpc++/support/sync_stream.h", "include/grpc++/support/time.h", "src/cpp/client/channel.cc", - "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", "src/cpp/client/create_channel_internal.cc", @@ -15545,6 +15544,7 @@ "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/common/call.cc", + "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/create_auth_context.h", "src/cpp/common/insecure_create_auth_context.cc", diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj index defd102577..663709d820 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -292,8 +292,6 @@ - - @@ -308,6 +306,8 @@ + + diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 97c484fcfc..05bb819dfa 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -7,9 +7,6 @@ src\cpp\client - - src\cpp\client - src\cpp\client @@ -31,6 +28,9 @@ src\cpp\common + + src\cpp\common + src\cpp\common diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index d2345cfd0d..2ddf4be334 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -291,22 +291,20 @@ - - + + - - @@ -321,6 +319,8 @@ + + diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 8c042215dc..782af6fc1c 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -1,9 +1,6 @@ - - src\cpp\client - src\cpp\client @@ -13,6 +10,9 @@ src\cpp\common + + src\cpp\common + src\cpp\common @@ -22,9 +22,6 @@ src\cpp\client - - src\cpp\client - src\cpp\client @@ -46,6 +43,9 @@ src\cpp\common + + src\cpp\common + src\cpp\common diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index defd102577..663709d820 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -292,8 +292,6 @@ - - @@ -308,6 +306,8 @@ + + diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 97c484fcfc..05bb819dfa 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -7,9 +7,6 @@ src\cpp\client - - src\cpp\client - src\cpp\client @@ -31,6 +28,9 @@ src\cpp\common + + src\cpp\common + src\cpp\common diff --git a/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj b/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj index aa1755af95..772f700b45 100644 --- a/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj +++ b/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj @@ -145,7 +145,7 @@ - + diff --git a/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj.filters b/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj.filters index 99153d2323..d2517f78c0 100644 --- a/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj.filters +++ b/vsprojects/vcxproj/test/channel_arguments_test/channel_arguments_test.vcxproj.filters @@ -1,8 +1,8 @@ - - test\cpp\client + + test\cpp\common @@ -13,8 +13,8 @@ {16fb3cfd-129c-a846-b9a5-dbec55fd83a8} - - {49a87562-f2d0-2d95-9dfa-87ebf2aed951} + + {641fdf8b-9e1d-4d66-c744-217b0b527616} -- cgit v1.2.3 From 92f4a155d8e8bf3003181451acc52e24bba5bcbc Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 2 Dec 2015 14:24:45 -0800 Subject: add doxygen comment --- include/grpc++/impl/server_builder_option.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/grpc++') diff --git a/include/grpc++/impl/server_builder_option.h b/include/grpc++/impl/server_builder_option.h index cf5c1d93e4..bcb19824fd 100644 --- a/include/grpc++/impl/server_builder_option.h +++ b/include/grpc++/impl/server_builder_option.h @@ -38,9 +38,11 @@ namespace grpc { +/// Interface to pass an option to a \a ServerBuilder. class ServerBuilderOption { public: virtual ~ServerBuilderOption() {} + /// Alter the \a ChannelArguments used to create the gRPC server. virtual void UpdateArguments(ChannelArguments* args) = 0; }; -- cgit v1.2.3 From 5b155e56746d50e0f6db1492c448d783db9dcdac Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 4 Dec 2015 16:57:06 -0800 Subject: more win x64 fixes --- include/grpc++/impl/rpc_service_method.h | 6 +++++- src/cpp/proto/proto_utils.cc | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'include/grpc++') diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index fcb0b7ccce..9d30d9627c 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -251,7 +251,11 @@ class RpcService { void AddMethod(RpcServiceMethod* method) { methods_.emplace_back(method); } RpcServiceMethod* GetMethod(int i) { return methods_[i].get(); } - int GetMethodCount() const { return methods_.size(); } + int GetMethodCount() const { + // On win x64, int is only 32bit + GPR_ASSERT(methods_.size() <= INT_MAX); + return (int)methods_.size(); + } private: std::vector> methods_; diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index b1330fde7f..0a05f29222 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -70,7 +70,9 @@ class GrpcBufferWriter GRPC_FINAL slice_ = gpr_slice_malloc(block_size_); } *data = GPR_SLICE_START_PTR(slice_); - byte_count_ += * size = GPR_SLICE_LENGTH(slice_); + // On win x64, int is only 32bit + GPR_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); gpr_slice_buffer_add(slice_buffer_, slice_); return true; } @@ -124,7 +126,9 @@ class GrpcBufferReader GRPC_FINAL } gpr_slice_unref(slice_); *data = GPR_SLICE_START_PTR(slice_); - byte_count_ += * size = GPR_SLICE_LENGTH(slice_); + // On win x64, int is only 32bit + GPR_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); return true; } -- cgit v1.2.3 From 5dc93c363b7422a0baae67f2db32713c264f405b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 7 Dec 2015 08:11:27 -0800 Subject: include climits --- include/grpc++/impl/rpc_service_method.h | 1 + src/cpp/proto/proto_utils.cc | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include/grpc++') diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 9d30d9627c..b203c8f53a 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -34,6 +34,7 @@ #ifndef GRPCXX_IMPL_RPC_SERVICE_METHOD_H #define GRPCXX_IMPL_RPC_SERVICE_METHOD_H +#include #include #include #include diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index 0a05f29222..898a1d4f58 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -33,6 +33,8 @@ #include +#include + #include #include #include -- cgit v1.2.3