diff options
author | ncteisen <ncteisen@gmail.com> | 2018-06-13 23:00:07 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-06-13 23:00:07 -0700 |
commit | f92460e539405bbca98af3547edd3150d0fcca40 (patch) | |
tree | dea35a54d1f6db8135df398c6e5a328ba3489609 | |
parent | 19ac7c0baf298be51c0dbfa7d5bcd1f45eec7c78 (diff) | |
parent | 9a2c0a8641d1837185a60436adf9419209f89fbe (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into channelz
271 files changed, 7727 insertions, 5053 deletions
diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..b8f74e973f --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,6 @@ +--- +Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size' +WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size' +CheckOptions: + - key: readability-function-size.StatementThreshold + value: '450' @@ -72,6 +72,13 @@ disable= # TODO(https://github.com/grpc/grpc/issues/261): Maybe we could have # this one if we extracted just a few more helper functions... too-many-nested-blocks, - # NOTE(nathaniel): I have disputed the premise of this inspection from - # the beginning and will continue to do so until it goes away for good. + # TODO(https://github.com/grpc/grpc/issues/261): Disable unnecessary + # super-init requirement for abstract class implementations for now. + super-init-not-called, + # NOTE(nathaniel): A single statement that always returns program + # control is better than two statements the first of which sometimes + # returns program control and the second of which always returns + # program control. Probably generally, but definitely in the cases of + # if:/else: and for:/else:. useless-else-on-loop, + no-else-return, diff --git a/.pylintrc-tests b/.pylintrc-tests index b358b2c4a0..ebe9d507cd 100644 --- a/.pylintrc-tests +++ b/.pylintrc-tests @@ -103,6 +103,13 @@ disable= # TODO(https://github.com/grpc/grpc/issues/261): Maybe we could have # this one if we extracted just a few more helper functions... too-many-nested-blocks, - # NOTE(nathaniel): I have disputed the premise of this inspection from - # the beginning and will continue to do so until it goes away for good. + # TODO(https://github.com/grpc/grpc/issues/261): Disable unnecessary + # super-init requirement for abstract class implementations for now. + super-init-not-called, + # NOTE(nathaniel): A single statement that always returns program + # control is better than two statements the first of which sometimes + # returns program control and the second of which always returns + # program control. Probably generally, but definitely in the cases of + # if:/else: and for:/else:. useless-else-on-loop, + no-else-return, @@ -1006,6 +1006,25 @@ grpc_cc_library( ) grpc_cc_library( + name = "grpc_cfstream", + srcs = [ + "src/core/lib/iomgr/cfstream_handle.cc", + "src/core/lib/iomgr/endpoint_cfstream.cc", + "src/core/lib/iomgr/error_cfstream.cc", + "src/core/lib/iomgr/tcp_client_cfstream.cc", + ], + hdrs = [ + "src/core/lib/iomgr/cfstream_handle.h", + "src/core/lib/iomgr/endpoint_cfstream.h", + "src/core/lib/iomgr/error_cfstream.h", + ], + deps = [ + ":gpr_base", + ":grpc_base", + ], +) + +grpc_cc_library( name = "grpc_client_channel", srcs = [ "src/core/ext/filters/client_channel/backup_poller.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index de3cb55fd4..4a62cb8c44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -664,6 +664,9 @@ endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx address_sorting_test) endif() +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) +add_dependencies(buildtests_cxx cancel_ares_query_test) +endif() add_custom_target(buildtests DEPENDS buildtests_c buildtests_cxx) @@ -701,6 +704,7 @@ target_include_directories(address_sorting ) target_link_libraries(address_sorting + ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} ) @@ -5305,6 +5309,7 @@ add_library(end2end_tests test/core/end2end/tests/max_message_length.cc test/core/end2end/tests/negative_deadline.cc test/core/end2end/tests/network_status_change.cc + test/core/end2end/tests/no_error_on_hotpath.cc test/core/end2end/tests/no_logging.cc test/core/end2end/tests/no_op.cc test/core/end2end/tests/payload.cc @@ -5424,6 +5429,7 @@ add_library(end2end_nosec_tests test/core/end2end/tests/max_message_length.cc test/core/end2end/tests/negative_deadline.cc test/core/end2end/tests/network_status_change.cc + test/core/end2end/tests/no_error_on_hotpath.cc test/core/end2end/tests/no_logging.cc test/core/end2end/tests/no_op.cc test/core/end2end/tests/payload.cc @@ -15897,6 +15903,48 @@ target_link_libraries(address_sorting_test endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + +add_executable(cancel_ares_query_test + test/cpp/naming/cancel_ares_query_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(cancel_ares_query_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(cancel_ares_query_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + gpr_test_util + grpc++ + grpc + gpr + grpc++_test_config + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) add_executable(alts_credentials_fuzzer_one_entry test/core/security/alts_credentials_fuzzer.cc @@ -1317,6 +1317,7 @@ resolver_component_tests_runner_invoker_unsecure: $(BINDIR)/$(CONFIG)/resolver_c resolver_component_tests_runner_invoker: $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker address_sorting_test_unsecure: $(BINDIR)/$(CONFIG)/address_sorting_test_unsecure address_sorting_test: $(BINDIR)/$(CONFIG)/address_sorting_test +cancel_ares_query_test: $(BINDIR)/$(CONFIG)/cancel_ares_query_test alts_credentials_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry api_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry client_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry @@ -1755,6 +1756,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker \ $(BINDIR)/$(CONFIG)/address_sorting_test_unsecure \ $(BINDIR)/$(CONFIG)/address_sorting_test \ + $(BINDIR)/$(CONFIG)/cancel_ares_query_test \ else buildtests_cxx: privatelibs_cxx \ @@ -1880,6 +1882,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker \ $(BINDIR)/$(CONFIG)/address_sorting_test_unsecure \ $(BINDIR)/$(CONFIG)/address_sorting_test \ + $(BINDIR)/$(CONFIG)/cancel_ares_query_test \ endif @@ -2367,6 +2370,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/address_sorting_test_unsecure || ( echo test address_sorting_test_unsecure failed ; exit 1 ) $(E) "[RUN] Testing address_sorting_test" $(Q) $(BINDIR)/$(CONFIG)/address_sorting_test || ( echo test address_sorting_test failed ; exit 1 ) + $(E) "[RUN] Testing cancel_ares_query_test" + $(Q) $(BINDIR)/$(CONFIG)/cancel_ares_query_test || ( echo test cancel_ares_query_test failed ; exit 1 ) flaky_test_cxx: buildtests_cxx @@ -10003,6 +10008,7 @@ LIBEND2END_TESTS_SRC = \ test/core/end2end/tests/max_message_length.cc \ test/core/end2end/tests/negative_deadline.cc \ test/core/end2end/tests/network_status_change.cc \ + test/core/end2end/tests/no_error_on_hotpath.cc \ test/core/end2end/tests/no_logging.cc \ test/core/end2end/tests/no_op.cc \ test/core/end2end/tests/payload.cc \ @@ -10120,6 +10126,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \ test/core/end2end/tests/max_message_length.cc \ test/core/end2end/tests/negative_deadline.cc \ test/core/end2end/tests/network_status_change.cc \ + test/core/end2end/tests/no_error_on_hotpath.cc \ test/core/end2end/tests/no_logging.cc \ test/core/end2end/tests/no_op.cc \ test/core/end2end/tests/payload.cc \ @@ -23747,6 +23754,49 @@ endif endif +CANCEL_ARES_QUERY_TEST_SRC = \ + test/cpp/naming/cancel_ares_query_test.cc \ + +CANCEL_ARES_QUERY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CANCEL_ARES_QUERY_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/cancel_ares_query_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/cancel_ares_query_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/cancel_ares_query_test: $(PROTOBUF_DEP) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/cancel_ares_query_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/naming/cancel_ares_query_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +deps_cancel_ares_query_test: $(CANCEL_ARES_QUERY_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CANCEL_ARES_QUERY_TEST_OBJS:.o=.dep) +endif +endif + + ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_SRC = \ test/core/security/alts_credentials_fuzzer.cc \ test/core/util/one_corpus_entry_fuzzer.cc \ diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 095b1596c8..687ff67914 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -62,7 +62,7 @@ def _maybe_update_cc_library_hdrs(hdrs): def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++", testonly = False, visibility = None, - alwayslink = 0): + alwayslink = 0, data = []): copts = [] if language.upper() == "C": copts = if_not_windows(["-std=c99"]) @@ -87,6 +87,7 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], "include" ], alwayslink = alwayslink, + data = data, ) def grpc_proto_plugin(name, srcs = [], deps = []): @@ -110,7 +111,7 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False, generate_mocks = generate_mocks, ) -def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = "moderate"): +def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = "moderate", tags = []): copts = [] if language.upper() == "C": copts = if_not_windows(["-std=c99"]) @@ -140,6 +141,7 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data poller, '$(location %s)' % name, ] + args['args'], + tags = tags, ) else: native.cc_test(**args) diff --git a/build.yaml b/build.yaml index 90a9f9c5a7..adb61ab56f 100644 --- a/build.yaml +++ b/build.yaml @@ -538,6 +538,19 @@ filegroups: uses: - grpc_codegen - grpc_trace_headers +- name: grpc_cfstream + headers: + - src/core/lib/iomgr/cfstream_handle.h + - src/core/lib/iomgr/endpoint_cfstream.h + - src/core/lib/iomgr/error_cfstream.h + src: + - src/core/lib/iomgr/cfstream_handle.cc + - src/core/lib/iomgr/endpoint_cfstream.cc + - src/core/lib/iomgr/error_cfstream.cc + - src/core/lib/iomgr/tcp_client_cfstream.cc + uses: + - grpc_base_headers + - gpr_base_headers - name: grpc_client_authority_filter headers: - src/core/ext/filters/http/client_authority_filter.h @@ -2021,6 +2034,7 @@ targets: dict: test/core/end2end/fuzzers/api_fuzzer.dictionary maxlen: 2048 - name: arena_test + cpu_cost: 10 build: test language: c src: diff --git a/doc/PROTOCOL-WEB.md b/doc/PROTOCOL-WEB.md index 5100c9b555..a06dfb1b54 100644 --- a/doc/PROTOCOL-WEB.md +++ b/doc/PROTOCOL-WEB.md @@ -138,4 +138,4 @@ Versioning Browser-specific features -* For features that are unique to browser or HTML clients, check the [spec doc](https://github.com/grpc/grpc-web/blob/master/PROTOCOL-WEB.md) published in the grpc/grpc-web repo. +* For features that are unique to browser or HTML clients, check the [spec doc](https://github.com/grpc/grpc-web/blob/master/BROWSER-FEATURES.md) published in the grpc/grpc-web repo. diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2a9ad86f03..70134dc0a6 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1083,6 +1083,24 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_utils.h' end + s.subspec 'CFStream-Implementation' do |ss| + ss.header_mappings_dir = '.' + ss.dependency "#{s.name}/Implementation", version + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + ss.source_files = 'src/core/lib/iomgr/cfstream_handle.cc', + 'src/core/lib/iomgr/endpoint_cfstream.cc', + 'src/core/lib/iomgr/error_cfstream.cc', + 'src/core/lib/iomgr/tcp_client_cfstream.cc', + 'src/core/lib/iomgr/cfstream_handle.h', + 'src/core/lib/iomgr/endpoint_cfstream.h', + 'src/core/lib/iomgr/error_cfstream.h' + ss.private_header_files = 'src/core/lib/iomgr/cfstream_handle.h', + 'src/core/lib/iomgr/endpoint_cfstream.h', + 'src/core/lib/iomgr/error_cfstream.h' + end + s.subspec 'Cronet-Interface' do |ss| ss.header_mappings_dir = 'include/grpc' ss.source_files = 'include/grpc/grpc_cronet.h' @@ -1202,6 +1220,7 @@ Pod::Spec.new do |s| 'test/core/end2end/tests/max_message_length.cc', 'test/core/end2end/tests/negative_deadline.cc', 'test/core/end2end/tests/network_status_change.cc', + 'test/core/end2end/tests/no_error_on_hotpath.cc', 'test/core/end2end/tests/no_logging.cc', 'test/core/end2end/tests/no_op.cc', 'test/core/end2end/tests/payload.cc', diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 17e650c264..039f3d412b 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -41,12 +41,25 @@ Pod::Spec.new do |s| s.header_dir = name src_dir = 'src/objective-c/ProtoRPC' - s.source_files = "#{src_dir}/*.{h,m}" - s.header_mappings_dir = "#{src_dir}" - s.dependency 'gRPC', version - s.dependency 'gRPC-RxLibrary', version - s.dependency 'Protobuf', '~> 3.0' + s.default_subspec = 'Main' + + s.subspec 'Main' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.dependency 'gRPC', version + ss.dependency 'gRPC-RxLibrary', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "#{src_dir}/*.{h,m}" + end + s.subspec 'CFStream' do |ss| + ss.dependency 'gRPC/CFStream', version + ss.dependency "#{s.name}/Main", version + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + end + s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', diff --git a/gRPC.podspec b/gRPC.podspec index afc4581091..a1d7720628 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -63,6 +63,16 @@ Pod::Spec.new do |s| ss.dependency 'gRPC-Core', version end + # This subspec is mutually exclusive with the `Main` subspec + s.subspec 'CFStream' do |ss| + ss.dependency 'gRPC-Core/CFStream-Implementation', version + ss.dependency "#{s.name}/Main", version + + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + end + s.subspec 'GID' do |ss| ss.ios.deployment_target = '7.0' @@ -2635,6 +2635,7 @@ 'test/core/end2end/tests/max_message_length.cc', 'test/core/end2end/tests/negative_deadline.cc', 'test/core/end2end/tests/network_status_change.cc', + 'test/core/end2end/tests/no_error_on_hotpath.cc', 'test/core/end2end/tests/no_logging.cc', 'test/core/end2end/tests/no_op.cc', 'test/core/end2end/tests/payload.cc', @@ -2726,6 +2727,7 @@ 'test/core/end2end/tests/max_message_length.cc', 'test/core/end2end/tests/negative_deadline.cc', 'test/core/end2end/tests/network_status_change.cc', + 'test/core/end2end/tests/no_error_on_hotpath.cc', 'test/core/end2end/tests/no_logging.cc', 'test/core/end2end/tests/no_op.cc', 'test/core/end2end/tests/payload.cc', diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 022be5fec4..a5961857c1 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -332,10 +332,12 @@ typedef struct { #define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" /** Channel arg that carries the bridged objective c object for custom metrics * logging filter. */ -#define GRPC_ARG_MOBILE_LOG_CONFIG "grpc.mobile_log_config" +#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context" /** If non-zero, client authority filter is disabled for the channel */ #define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ "grpc.disable_client_authority_filter" +/** If set to zero, disables use of http proxies. Enabled by default. */ +#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy" /** \} */ /** Result of a grpc call. If the caller satisfies the prerequisites of a diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index bf1bf3df6a..01ce5f03e9 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -227,7 +227,10 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_GETPID_IN_UNISTD_H 1 +/* TODO(mxyan): Remove when CFStream becomes default */ +#ifndef GRPC_CFSTREAM #define GPR_SUPPORT_CHANNELS_FROM_FD 1 +#endif #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h index 28cc4a9e20..e324f6b14d 100644 --- a/include/grpcpp/impl/codegen/call.h +++ b/include/grpcpp/impl/codegen/call.h @@ -573,10 +573,13 @@ class CallOpClientRecvStatus { binary_error_details = grpc::string(iter->second.begin(), iter->second.length()); } - *recv_status_ = Status(static_cast<StatusCode>(status_code_), - grpc::string(GRPC_SLICE_START_PTR(error_message_), - GRPC_SLICE_END_PTR(error_message_)), - binary_error_details); + *recv_status_ = + Status(static_cast<StatusCode>(status_code_), + GRPC_SLICE_IS_EMPTY(error_message_) + ? grpc::string() + : grpc::string(GRPC_SLICE_START_PTR(error_message_), + GRPC_SLICE_END_PTR(error_message_)), + binary_error_details); client_context_->set_debug_error_string( debug_error_string_ != nullptr ? debug_error_string_ : ""); g_core_codegen_interface->grpc_slice_unref(error_message_); diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index cf330ac352..237991cde6 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -49,12 +49,35 @@ class ServerInterface : public internal::CallHook { public: virtual ~ServerInterface() {} - /// Shutdown the server, blocking until all rpc processing finishes. - /// Forcefully terminate pending calls after \a deadline expires. + /// \a Shutdown does the following things: + /// + /// 1. Shutdown the server: deactivate all listening ports, mark it in + /// "shutdown mode" so that further call Request's or incoming RPC matches + /// are no longer allowed. Also return all Request'ed-but-not-yet-active + /// calls as failed (!ok). This refers to calls that have been requested + /// at the server by the server-side library or application code but that + /// have not yet been matched to incoming RPCs from the client. Note that + /// this would even include default calls added automatically by the gRPC + /// C++ API without the user's input (e.g., "Unimplemented RPC method") + /// + /// 2. Block until all rpc method handlers invoked automatically by the sync + /// API finish. + /// + /// 3. If all pending calls complete (and all their operations are + /// retrieved by Next) before \a deadline expires, this finishes + /// gracefully. Otherwise, forcefully cancel all pending calls associated + /// with the server after \a deadline expires. In the case of the sync API, + /// if the RPC function for a streaming call has already been started and + /// takes a week to complete, the RPC function won't be forcefully + /// terminated (since that would leave state corrupt and incomplete) and + /// the method handler will just keep running (which will prevent the + /// server from completing the "join" operation that it needs to do at + /// shutdown time). /// /// All completion queue associated with the server (for example, for async /// serving) must be shutdown *after* this method has returned: /// See \a ServerBuilder::AddCompletionQueue for details. + /// They must also be drained (by repeated Next) after being shutdown. /// /// \param deadline How long to wait until pending rpcs are forcefully /// terminated. @@ -63,7 +86,7 @@ class ServerInterface : public internal::CallHook { ShutdownInternal(TimePoint<T>(deadline).raw_time()); } - /// Shutdown the server, waiting for all rpc processing to finish. + /// Shutdown the server without a deadline and forced cancellation. /// /// All completion queue associated with the server (for example, for async /// serving) must be shutdown *after* this method has returned: diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index 4c8dcf4916..a58a59c2d8 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -86,8 +86,8 @@ class ServerBuilder { /// \param creds The credentials associated with the server. /// \param selected_port[out] If not `nullptr`, gets populated with the port /// number bound to the \a grpc::Server for the corresponding endpoint after - /// it is successfully bound, 0 otherwise. - /// + /// it is successfully bound by BuildAndStart(), 0 otherwise. AddListeningPort + /// does not modify this pointer. ServerBuilder& AddListeningPort(const grpc::string& addr_uri, std::shared_ptr<ServerCredentials> creds, int* selected_port = nullptr); @@ -144,12 +144,14 @@ class ServerBuilder { // Fine control knobs /// Set max receive message size in bytes. + /// The default is GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH. ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) { max_receive_message_size_ = max_receive_message_size; return *this; } /// Set max send message size in bytes. + /// The default is GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH. ServerBuilder& SetMaxSendMessageSize(int max_send_message_size) { max_send_message_size_ = max_send_message_size; return *this; diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 14173e0794..a923ce8e38 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -202,7 +202,8 @@ std::string GetCSharpMethodType(MethodType method_type) { std::string GetServiceNameFieldName() { return "__ServiceName"; } std::string GetMarshallerFieldName(const Descriptor* message) { - return "__Marshaller_" + message->name(); + return "__Marshaller_" + + grpc_generator::StringReplace(message->full_name(), ".", "_", true); } std::string GetMethodFieldName(const MethodDescriptor* method) { @@ -680,14 +681,19 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client, out.Print("using grpc = global::Grpc.Core;\n"); out.Print("\n"); - out.Print("namespace $namespace$ {\n", "namespace", GetFileNamespace(file)); - out.Indent(); + grpc::string file_namespace = GetFileNamespace(file); + if (file_namespace != "") { + out.Print("namespace $namespace$ {\n", "namespace", file_namespace); + out.Indent(); + } for (int i = 0; i < file->service_count(); i++) { GenerateService(&out, file->service(i), generate_client, generate_server, internal_access); } - out.Outdent(); - out.Print("}\n"); + if (file_namespace != "") { + out.Outdent(); + out.Print("}\n"); + } out.Print("#endregion\n"); } return output; diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index ea6775a8d8..f141aabe70 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -327,16 +327,14 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { if (chand->resolver_result != nullptr) { if (chand->resolver != nullptr) { // Find LB policy name. - const grpc_arg* channel_arg = grpc_channel_args_find( + const char* lb_policy_name = grpc_channel_args_get_string( chand->resolver_result, GRPC_ARG_LB_POLICY_NAME); - const char* lb_policy_name = grpc_channel_arg_get_string(channel_arg); // Special case: If at least one balancer address is present, we use // the grpclb policy, regardless of what the resolver actually specified. - channel_arg = - grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES); - if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) { - grpc_lb_addresses* addresses = - static_cast<grpc_lb_addresses*>(channel_arg->value.pointer.p); + grpc_lb_addresses* addresses = + grpc_channel_args_get_pointer<grpc_lb_addresses>( + chand->resolver_result, GRPC_ARG_LB_ADDRESSES); + if (addresses != nullptr) { bool found_balancer_address = false; for (size_t i = 0; i < addresses->num_addresses; ++i) { if (addresses->addresses[i].is_balancer) { @@ -400,18 +398,15 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { // The copy will be saved in chand->lb_policy_name below. lb_policy_name_dup = gpr_strdup(lb_policy_name); // Find service config. - channel_arg = grpc_channel_args_find(chand->resolver_result, - GRPC_ARG_SERVICE_CONFIG); - service_config_json = - gpr_strdup(grpc_channel_arg_get_string(channel_arg)); + service_config_json = gpr_strdup(grpc_channel_args_get_string( + chand->resolver_result, GRPC_ARG_SERVICE_CONFIG)); if (service_config_json != nullptr) { grpc_core::UniquePtr<grpc_core::ServiceConfig> service_config = grpc_core::ServiceConfig::Create(service_config_json); if (service_config != nullptr) { if (chand->enable_retries) { - channel_arg = grpc_channel_args_find(chand->resolver_result, - GRPC_ARG_SERVER_URI); - const char* server_uri = grpc_channel_arg_get_string(channel_arg); + const char* server_uri = grpc_channel_args_get_string( + chand->resolver_result, GRPC_ARG_SERVER_URI); GPR_ASSERT(server_uri != nullptr); grpc_uri* uri = grpc_uri_parse(server_uri, true); GPR_ASSERT(uri->path[0] != '\0'); @@ -648,45 +643,37 @@ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem, "client_channel"); grpc_client_channel_start_backup_polling(chand->interested_parties); // Record max per-RPC retry buffer size. - const grpc_arg* arg = grpc_channel_args_find( - args->channel_args, GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE); - chand->per_rpc_retry_buffer_size = (size_t)grpc_channel_arg_get_integer( - arg, {DEFAULT_PER_RPC_RETRY_BUFFER_SIZE, 0, INT_MAX}); + chand->per_rpc_retry_buffer_size = (size_t)grpc_channel_args_get_integer( + args->channel_args, GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE, + {DEFAULT_PER_RPC_RETRY_BUFFER_SIZE, 0, INT_MAX}); // Record enable_retries. - arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_ENABLE_RETRIES); - chand->enable_retries = grpc_channel_arg_get_bool(arg, true); + chand->enable_retries = grpc_channel_args_get_bool( + args->channel_args, GRPC_ARG_ENABLE_RETRIES, true); // Record client channel factory. - arg = grpc_channel_args_find(args->channel_args, - GRPC_ARG_CLIENT_CHANNEL_FACTORY); - if (arg == nullptr) { + grpc_client_channel_factory* client_channel_factory = + grpc_channel_args_get_pointer<grpc_client_channel_factory>( + args->channel_args, GRPC_ARG_CLIENT_CHANNEL_FACTORY); + if (client_channel_factory == nullptr) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Missing client channel factory in args for client channel filter"); + "Missing or malformed client channel factory in args for client " + "channel filter"); } - if (arg->type != GRPC_ARG_POINTER) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "client channel factory arg must be a pointer"); - } - grpc_client_channel_factory_ref( - static_cast<grpc_client_channel_factory*>(arg->value.pointer.p)); - chand->client_channel_factory = - static_cast<grpc_client_channel_factory*>(arg->value.pointer.p); + grpc_client_channel_factory_ref(client_channel_factory); + chand->client_channel_factory = client_channel_factory; // Get server name to resolve, using proxy mapper if needed. - arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI); - if (arg == nullptr) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Missing server uri in args for client channel filter"); - } - if (arg->type != GRPC_ARG_STRING) { + char* server_uri = + grpc_channel_args_get_string(args->channel_args, GRPC_ARG_SERVER_URI); + if (server_uri == nullptr) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "server uri arg must be a string"); + "Missing or malformed server uri in args for client channel filter"); } char* proxy_name = nullptr; grpc_channel_args* new_args = nullptr; - grpc_proxy_mappers_map_name(arg->value.string, args->channel_args, - &proxy_name, &new_args); + grpc_proxy_mappers_map_name(server_uri, args->channel_args, &proxy_name, + &new_args); // Instantiate resolver. chand->resolver = grpc_core::ResolverRegistry::CreateResolver( - proxy_name != nullptr ? proxy_name : arg->value.string, + proxy_name != nullptr ? proxy_name : server_uri, new_args != nullptr ? new_args : args->channel_args, chand->interested_parties, chand->combiner); if (proxy_name != nullptr) gpr_free(proxy_name); diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc index 4e8b8b71db..58f059829c 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc @@ -254,9 +254,8 @@ static void http_connect_handshaker_do_handshake( reinterpret_cast<http_connect_handshaker*>(handshaker_in); // Check for HTTP CONNECT channel arg. // If not found, invoke on_handshake_done without doing anything. - const grpc_arg* arg = - grpc_channel_args_find(args->args, GRPC_ARG_HTTP_CONNECT_SERVER); - char* server_name = grpc_channel_arg_get_string(arg); + char* server_name = + grpc_channel_args_get_string(args->args, GRPC_ARG_HTTP_CONNECT_SERVER); if (server_name == nullptr) { // Set shutdown to true so that subsequent calls to // http_connect_handshaker_shutdown() do nothing. @@ -267,8 +266,8 @@ static void http_connect_handshaker_do_handshake( return; } // Get headers from channel args. - arg = grpc_channel_args_find(args->args, GRPC_ARG_HTTP_CONNECT_HEADERS); - char* arg_header_string = grpc_channel_arg_get_string(arg); + char* arg_header_string = + grpc_channel_args_get_string(args->args, GRPC_ARG_HTTP_CONNECT_HEADERS); grpc_http_header* headers = nullptr; size_t num_headers = 0; char** header_strings = nullptr; diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 29a6c0e367..e21de35a7d 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -83,11 +83,22 @@ done: return proxy_name; } +/** + * Checks the value of GRPC_ARG_ENABLE_HTTP_PROXY to determine if http_proxy + * should be used. + */ +bool http_proxy_enabled(const grpc_channel_args* args) { + return grpc_channel_args_get_bool(args, GRPC_ARG_ENABLE_HTTP_PROXY, true); +} + static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, const char* server_uri, const grpc_channel_args* args, char** name_to_resolve, grpc_channel_args** new_args) { + if (!http_proxy_enabled(args)) { + return false; + } char* user_cred = nullptr; *name_to_resolve = get_http_proxy_server(&user_cred); if (*name_to_resolve == nullptr) return false; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 263b51ae89..0ee4958f3d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1045,8 +1045,8 @@ GrpcLb::GrpcLb(const grpc_lb_addresses* addresses, grpc_combiner_scheduler(args.combiner)); grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE, "grpclb"); // Record server name. - const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); - const char* server_uri = grpc_channel_arg_get_string(arg); + const char* server_uri = + grpc_channel_args_get_string(args.args, GRPC_ARG_SERVER_URI); GPR_ASSERT(server_uri != nullptr); grpc_uri* uri = grpc_uri_parse(server_uri, true); GPR_ASSERT(uri->path[0] != '\0'); @@ -1058,12 +1058,12 @@ GrpcLb::GrpcLb(const grpc_lb_addresses* addresses, } grpc_uri_destroy(uri); // Record LB call timeout. - arg = grpc_channel_args_find(args.args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS); - lb_call_timeout_ms_ = grpc_channel_arg_get_integer(arg, {0, 0, INT_MAX}); + lb_call_timeout_ms_ = grpc_channel_args_get_integer( + args.args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS, {0, 0, INT_MAX}); // Record fallback timeout. - arg = grpc_channel_args_find(args.args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS); - lb_fallback_timeout_ms_ = grpc_channel_arg_get_integer( - arg, {GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX}); + lb_fallback_timeout_ms_ = grpc_channel_args_get_integer( + args.args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS, + {GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX}); // Process channel args. ProcessChannelArgsLocked(*args.args); } @@ -1284,8 +1284,10 @@ void GrpcLb::NotifyOnStateChangeLocked(grpc_connectivity_state* current, } void GrpcLb::ProcessChannelArgsLocked(const grpc_channel_args& args) { - const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES); - if (GPR_UNLIKELY(arg == nullptr || arg->type != GRPC_ARG_POINTER)) { + const grpc_lb_addresses* addresses = + grpc_channel_args_get_pointer<grpc_lb_addresses>(&args, + GRPC_ARG_LB_ADDRESSES); + if (GPR_UNLIKELY(addresses == nullptr)) { // Ignore this update. gpr_log( GPR_ERROR, @@ -1293,8 +1295,6 @@ void GrpcLb::ProcessChannelArgsLocked(const grpc_channel_args& args) { this); return; } - const grpc_lb_addresses* addresses = - static_cast<const grpc_lb_addresses*>(arg->value.pointer.p); // Update fallback address list. if (fallback_backend_addresses_ != nullptr) { grpc_lb_addresses_destroy(fallback_backend_addresses_); @@ -1860,13 +1860,12 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory { OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy( const LoadBalancingPolicy::Args& args) const override { /* Count the number of gRPC-LB addresses. There must be at least one. */ - const grpc_arg* arg = - grpc_channel_args_find(args.args, GRPC_ARG_LB_ADDRESSES); - if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { + grpc_lb_addresses* addresses = + grpc_channel_args_get_pointer<grpc_lb_addresses>(args.args, + GRPC_ARG_LB_ADDRESSES); + if (addresses == nullptr) { return nullptr; } - grpc_lb_addresses* addresses = - static_cast<grpc_lb_addresses*>(arg->value.pointer.p); size_t num_grpclb_addrs = 0; for (size_t i = 0; i < addresses->num_addresses; ++i) { if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs; @@ -1893,10 +1892,9 @@ bool maybe_add_client_load_reporting_filter(grpc_channel_stack_builder* builder, void* arg) { const grpc_channel_args* args = grpc_channel_stack_builder_get_channel_arguments(builder); - const grpc_arg* channel_arg = - grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME); - if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING && - strcmp(channel_arg->value.string, "grpclb") == 0) { + const char* lb_policy = + grpc_channel_args_get_string(args, GRPC_ARG_LB_POLICY_NAME); + if (lb_policy != nullptr && strcmp(lb_policy, "grpclb") == 0) { return grpc_channel_stack_builder_append_filter( builder, (const grpc_channel_filter*)arg, nullptr, nullptr); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc index 441efd5e23..972bdd40d5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc @@ -72,11 +72,10 @@ grpc_channel_args* grpc_lb_policy_grpclb_modify_lb_channel_args( grpc_arg args_to_add[2]; size_t num_args_to_add = 0; // Add arg for targets info table. - const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_LB_ADDRESSES); - GPR_ASSERT(arg != nullptr); - GPR_ASSERT(arg->type == GRPC_ARG_POINTER); grpc_lb_addresses* addresses = - static_cast<grpc_lb_addresses*>(arg->value.pointer.p); + grpc_channel_args_get_pointer<grpc_lb_addresses>(args, + GRPC_ARG_LB_ADDRESSES); + GPR_ASSERT(addresses != nullptr); grpc_core::RefCountedPtr<grpc_core::TargetAuthorityTable> target_authority_table = grpc_core::CreateTargetAuthorityTable(addresses); args_to_add[num_args_to_add++] = diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index ff2140e628..70220e28d3 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -281,8 +281,10 @@ void PickFirst::PingOneLocked(grpc_closure* on_initiate, grpc_closure* on_ack) { } void PickFirst::UpdateLocked(const grpc_channel_args& args) { - const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES); - if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { + const grpc_lb_addresses* addresses = + grpc_channel_args_get_pointer<const grpc_lb_addresses>( + &args, GRPC_ARG_LB_ADDRESSES); + if (addresses == nullptr) { if (subchannel_list_ == nullptr) { // If we don't have a current subchannel list, go into TRANSIENT FAILURE. grpc_connectivity_state_set( @@ -298,8 +300,6 @@ void PickFirst::UpdateLocked(const grpc_channel_args& args) { } return; } - const grpc_lb_addresses* addresses = - static_cast<const grpc_lb_addresses*>(arg->value.pointer.p); if (grpc_lb_pick_first_trace.enabled()) { gpr_log(GPR_INFO, "Pick First %p received update with %" PRIuPTR " addresses", this, diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index b177385065..066f6ef7a6 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -607,8 +607,10 @@ void RoundRobin::PingOneLocked(grpc_closure* on_initiate, } void RoundRobin::UpdateLocked(const grpc_channel_args& args) { - const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES); - if (GPR_UNLIKELY(arg == nullptr || arg->type != GRPC_ARG_POINTER)) { + grpc_lb_addresses* addresses = + grpc_channel_args_get_pointer<grpc_lb_addresses>(&args, + GRPC_ARG_LB_ADDRESSES); + if (GPR_UNLIKELY(addresses == nullptr)) { gpr_log(GPR_ERROR, "[RR %p] update provided no addresses; ignoring", this); // If we don't have a current subchannel list, go into TRANSIENT_FAILURE. // Otherwise, keep using the current subchannel list (ignore this update). @@ -620,8 +622,6 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args) { } return; } - grpc_lb_addresses* addresses = - static_cast<grpc_lb_addresses*>(arg->value.pointer.p); if (grpc_lb_round_robin_trace.enabled()) { gpr_log(GPR_INFO, "[RR %p] received update with %" PRIuPTR " addresses", this, addresses->num_addresses); diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.cc b/src/core/ext/filters/client_channel/lb_policy_factory.cc index 7c8cba55b7..93dae753bf 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.cc +++ b/src/core/ext/filters/client_channel/lb_policy_factory.cc @@ -147,9 +147,6 @@ grpc_arg grpc_lb_addresses_create_channel_arg( grpc_lb_addresses* grpc_lb_addresses_find_channel_arg( const grpc_channel_args* channel_args) { - const grpc_arg* lb_addresses_arg = - grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES); - if (lb_addresses_arg == nullptr || lb_addresses_arg->type != GRPC_ARG_POINTER) - return nullptr; - return static_cast<grpc_lb_addresses*>(lb_addresses_arg->value.pointer.p); + return grpc_channel_args_get_pointer<grpc_lb_addresses>( + channel_args, GRPC_ARG_LB_ADDRESSES); } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 3c40ae14b8..01156b1e40 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -140,14 +140,11 @@ AresDnsResolver::AresDnsResolver(const ResolverArgs& args) dns_server_ = gpr_strdup(args.uri->authority); } channel_args_ = grpc_channel_args_copy(args.args); - const grpc_arg* arg = grpc_channel_args_find( - channel_args_, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION); - request_service_config_ = !grpc_channel_arg_get_integer( - arg, (grpc_integer_options){false, false, true}); - arg = grpc_channel_args_find(channel_args_, - GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); - min_time_between_resolutions_ = - grpc_channel_arg_get_integer(arg, {1000, 0, INT_MAX}); + request_service_config_ = !grpc_channel_args_get_bool( + channel_args_, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, false); + min_time_between_resolutions_ = grpc_channel_args_get_integer( + channel_args_, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS, + {1000, 0, INT_MAX}); interested_parties_ = grpc_pollset_set_create(); if (args.pollset_set != nullptr) { grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set); @@ -414,10 +411,10 @@ void AresDnsResolver::StartResolvingLocked() { resolving_ = true; lb_addresses_ = nullptr; service_config_json_ = nullptr; - pending_request_ = grpc_dns_lookup_ares( + pending_request_ = grpc_dns_lookup_ares_locked( dns_server_, name_to_resolve_, kDefaultPort, interested_parties_, &on_resolved_, &lb_addresses_, true /* check_grpclb */, - request_service_config_ ? &service_config_json_ : nullptr); + request_service_config_ ? &service_config_json_ : nullptr, combiner()); last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now(); } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h index 6239549534..27d1511d94 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -29,25 +29,27 @@ typedef struct grpc_ares_ev_driver grpc_ares_ev_driver; /* Start \a ev_driver. It will keep working until all IO on its ares_channel is done, or grpc_ares_ev_driver_destroy() is called. It may notify the callbacks bound to its ares_channel when necessary. */ -void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver); +void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver); /* Returns the ares_channel owned by \a ev_driver. To bind a c-ares query to \a ev_driver, use the ares_channel owned by \a ev_driver as the arg of the query. */ -ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver); +ares_channel* grpc_ares_ev_driver_get_channel_locked( + grpc_ares_ev_driver* ev_driver); /* Creates a new grpc_ares_ev_driver. Returns GRPC_ERROR_NONE if \a ev_driver is created successfully. */ -grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver, - grpc_pollset_set* pollset_set); +grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, + grpc_pollset_set* pollset_set, + grpc_combiner* combiner); /* Destroys \a ev_driver asynchronously. Pending lookups made on \a ev_driver will be cancelled and their on_done callbacks will be invoked with a status of ARES_ECANCELLED. */ -void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver); +void grpc_ares_ev_driver_destroy_locked(grpc_ares_ev_driver* ev_driver); /* Shutdown all the grpc_fds used by \a ev_driver */ -void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver); +void grpc_ares_ev_driver_shutdown_locked(grpc_ares_ev_driver* ev_driver); #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H \ */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index b604f2bf14..b73e979e9f 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -18,9 +18,10 @@ #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET) +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) #include <ares.h> +#include <string.h> #include <sys/ioctl.h> #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" @@ -38,25 +39,23 @@ typedef struct fd_node { /** the owner of this fd node */ grpc_ares_ev_driver* ev_driver; - /** a closure wrapping on_readable_cb, which should be invoked when the - grpc_fd in this node becomes readable. */ + /** a closure wrapping on_readable_locked, which should be + invoked when the grpc_fd in this node becomes readable. */ grpc_closure read_closure; - /** a closure wrapping on_writable_cb, which should be invoked when the - grpc_fd in this node becomes writable. */ + /** a closure wrapping on_writable_locked, which should be + invoked when the grpc_fd in this node becomes writable. */ grpc_closure write_closure; /** next fd node in the list */ struct fd_node* next; - /** mutex guarding the rest of the state */ - gpr_mu mu; /** the grpc_fd owned by this fd node */ grpc_fd* fd; /** if the readable closure has been registered */ bool readable_registered; /** if the writable closure has been registered */ bool writable_registered; - /** if the fd is being shut down */ - bool shutting_down; + /** if the fd has been shutdown yet from grpc iomgr perspective */ + bool already_shutdown; } fd_node; struct grpc_ares_ev_driver { @@ -67,8 +66,8 @@ struct grpc_ares_ev_driver { /** refcount of the event driver */ gpr_refcount refs; - /** mutex guarding the rest of the state */ - gpr_mu mu; + /** combiner to synchronize c-ares and I/O callbacks on */ + grpc_combiner* combiner; /** a list of grpc_fd that this event driver is currently using. */ fd_node* fds; /** is this event driver currently working? */ @@ -91,44 +90,42 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) { if (gpr_unref(&ev_driver->refs)) { gpr_log(GPR_DEBUG, "destroy ev_driver %" PRIuPTR, (uintptr_t)ev_driver); GPR_ASSERT(ev_driver->fds == nullptr); - gpr_mu_destroy(&ev_driver->mu); + GRPC_COMBINER_UNREF(ev_driver->combiner, "free ares event driver"); ares_destroy(ev_driver->channel); gpr_free(ev_driver); } } -static void fd_node_destroy(fd_node* fdn) { +static void fd_node_destroy_locked(fd_node* fdn) { gpr_log(GPR_DEBUG, "delete fd: %d", grpc_fd_wrapped_fd(fdn->fd)); GPR_ASSERT(!fdn->readable_registered); GPR_ASSERT(!fdn->writable_registered); - gpr_mu_destroy(&fdn->mu); - /* c-ares library has closed the fd inside grpc_fd. This fd may be picked up + GPR_ASSERT(fdn->already_shutdown); + /* c-ares library will close the fd inside grpc_fd. This fd may be picked up immediately by another thread, and should not be closed by the following grpc_fd_orphan. */ - grpc_fd_orphan(fdn->fd, nullptr, nullptr, true /* already_closed */, - "c-ares query finished"); + int dummy_release_fd; + grpc_fd_orphan(fdn->fd, nullptr, &dummy_release_fd, "c-ares query finished"); gpr_free(fdn); } -static void fd_node_shutdown(fd_node* fdn) { - gpr_mu_lock(&fdn->mu); - fdn->shutting_down = true; - if (!fdn->readable_registered && !fdn->writable_registered) { - gpr_mu_unlock(&fdn->mu); - fd_node_destroy(fdn); - } else { - grpc_fd_shutdown( - fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("c-ares fd shutdown")); - gpr_mu_unlock(&fdn->mu); +static void fd_node_shutdown_locked(fd_node* fdn, const char* reason) { + if (!fdn->already_shutdown) { + fdn->already_shutdown = true; + grpc_fd_shutdown(fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(reason)); } } -grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver, - grpc_pollset_set* pollset_set) { +grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, + grpc_pollset_set* pollset_set, + grpc_combiner* combiner) { *ev_driver = static_cast<grpc_ares_ev_driver*>( gpr_malloc(sizeof(grpc_ares_ev_driver))); - int status = ares_init(&(*ev_driver)->channel); - gpr_log(GPR_DEBUG, "grpc_ares_ev_driver_create"); + ares_options opts; + memset(&opts, 0, sizeof(opts)); + opts.flags |= ARES_FLAG_STAYOPEN; + int status = ares_init_options(&(*ev_driver)->channel, &opts, ARES_OPT_FLAGS); + gpr_log(GPR_DEBUG, "grpc_ares_ev_driver_create_locked"); if (status != ARES_SUCCESS) { char* err_msg; gpr_asprintf(&err_msg, "Failed to init ares channel. C-ares error: %s", @@ -138,7 +135,7 @@ grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver, gpr_free(*ev_driver); return err; } - gpr_mu_init(&(*ev_driver)->mu); + (*ev_driver)->combiner = GRPC_COMBINER_REF(combiner, "ares event driver"); gpr_ref_init(&(*ev_driver)->refs, 1); (*ev_driver)->pollset_set = pollset_set; (*ev_driver)->fds = nullptr; @@ -147,33 +144,26 @@ grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver, return GRPC_ERROR_NONE; } -void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver) { - // It's not safe to shut down remaining fds here directly, becauses - // ares_host_callback does not provide an exec_ctx. We mark the event driver - // as being shut down. If the event driver is working, - // grpc_ares_notify_on_event_locked will shut down the fds; if it's not - // working, there are no fds to shut down. - gpr_mu_lock(&ev_driver->mu); +void grpc_ares_ev_driver_destroy_locked(grpc_ares_ev_driver* ev_driver) { + // We mark the event driver as being shut down. If the event driver + // is working, grpc_ares_notify_on_event_locked will shut down the + // fds; if it's not working, there are no fds to shut down. ev_driver->shutting_down = true; - gpr_mu_unlock(&ev_driver->mu); grpc_ares_ev_driver_unref(ev_driver); } -void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver) { - gpr_mu_lock(&ev_driver->mu); +void grpc_ares_ev_driver_shutdown_locked(grpc_ares_ev_driver* ev_driver) { ev_driver->shutting_down = true; fd_node* fn = ev_driver->fds; while (fn != nullptr) { - grpc_fd_shutdown(fn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "grpc_ares_ev_driver_shutdown")); + fd_node_shutdown_locked(fn, "grpc_ares_ev_driver_shutdown"); fn = fn->next; } - gpr_mu_unlock(&ev_driver->mu); } // Search fd in the fd_node list head. This is an O(n) search, the max possible // value of n is ARES_GETSOCK_MAXNUM (16). n is typically 1 - 2 in our tests. -static fd_node* pop_fd_node(fd_node** head, int fd) { +static fd_node* pop_fd_node_locked(fd_node** head, int fd) { fd_node dummy_head; dummy_head.next = *head; fd_node* node = &dummy_head; @@ -190,31 +180,22 @@ static fd_node* pop_fd_node(fd_node** head, int fd) { } /* Check if \a fd is still readable */ -static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver* ev_driver, - int fd) { +static bool grpc_ares_is_fd_still_readable_locked( + grpc_ares_ev_driver* ev_driver, int fd) { size_t bytes_available = 0; return ioctl(fd, FIONREAD, &bytes_available) == 0 && bytes_available > 0; } -static void on_readable_cb(void* arg, grpc_error* error) { +static void on_readable_locked(void* arg, grpc_error* error) { fd_node* fdn = static_cast<fd_node*>(arg); grpc_ares_ev_driver* ev_driver = fdn->ev_driver; - gpr_mu_lock(&fdn->mu); const int fd = grpc_fd_wrapped_fd(fdn->fd); fdn->readable_registered = false; - if (fdn->shutting_down && !fdn->writable_registered) { - gpr_mu_unlock(&fdn->mu); - fd_node_destroy(fdn); - grpc_ares_ev_driver_unref(ev_driver); - return; - } - gpr_mu_unlock(&fdn->mu); - gpr_log(GPR_DEBUG, "readable on %d", fd); if (error == GRPC_ERROR_NONE) { do { ares_process_fd(ev_driver->channel, fd, ARES_SOCKET_BAD); - } while (grpc_ares_is_fd_still_readable(ev_driver, fd)); + } while (grpc_ares_is_fd_still_readable_locked(ev_driver, fd)); } else { // If error is not GRPC_ERROR_NONE, it means the fd has been shutdown or // timed out. The pending lookups made on this ev_driver will be cancelled @@ -224,26 +205,15 @@ static void on_readable_cb(void* arg, grpc_error* error) { // grpc_ares_notify_on_event_locked(). ares_cancel(ev_driver->channel); } - gpr_mu_lock(&ev_driver->mu); grpc_ares_notify_on_event_locked(ev_driver); - gpr_mu_unlock(&ev_driver->mu); grpc_ares_ev_driver_unref(ev_driver); } -static void on_writable_cb(void* arg, grpc_error* error) { +static void on_writable_locked(void* arg, grpc_error* error) { fd_node* fdn = static_cast<fd_node*>(arg); grpc_ares_ev_driver* ev_driver = fdn->ev_driver; - gpr_mu_lock(&fdn->mu); const int fd = grpc_fd_wrapped_fd(fdn->fd); fdn->writable_registered = false; - if (fdn->shutting_down && !fdn->readable_registered) { - gpr_mu_unlock(&fdn->mu); - fd_node_destroy(fdn); - grpc_ares_ev_driver_unref(ev_driver); - return; - } - gpr_mu_unlock(&fdn->mu); - gpr_log(GPR_DEBUG, "writable on %d", fd); if (error == GRPC_ERROR_NONE) { ares_process_fd(ev_driver->channel, ARES_SOCKET_BAD, fd); @@ -256,13 +226,12 @@ static void on_writable_cb(void* arg, grpc_error* error) { // grpc_ares_notify_on_event_locked(). ares_cancel(ev_driver->channel); } - gpr_mu_lock(&ev_driver->mu); grpc_ares_notify_on_event_locked(ev_driver); - gpr_mu_unlock(&ev_driver->mu); grpc_ares_ev_driver_unref(ev_driver); } -ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver) { +ares_channel* grpc_ares_ev_driver_get_channel_locked( + grpc_ares_ev_driver* ev_driver) { return &ev_driver->channel; } @@ -277,29 +246,27 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) { for (size_t i = 0; i < ARES_GETSOCK_MAXNUM; i++) { if (ARES_GETSOCK_READABLE(socks_bitmask, i) || ARES_GETSOCK_WRITABLE(socks_bitmask, i)) { - fd_node* fdn = pop_fd_node(&ev_driver->fds, socks[i]); + fd_node* fdn = pop_fd_node_locked(&ev_driver->fds, socks[i]); // Create a new fd_node if sock[i] is not in the fd_node list. if (fdn == nullptr) { char* fd_name; gpr_asprintf(&fd_name, "ares_ev_driver-%" PRIuPTR, i); fdn = static_cast<fd_node*>(gpr_malloc(sizeof(fd_node))); gpr_log(GPR_DEBUG, "new fd: %d", socks[i]); - fdn->fd = grpc_fd_create(socks[i], fd_name); + fdn->fd = grpc_fd_create(socks[i], fd_name, false); fdn->ev_driver = ev_driver; fdn->readable_registered = false; fdn->writable_registered = false; - fdn->shutting_down = false; - gpr_mu_init(&fdn->mu); - GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable_cb, fdn, - grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_cb, fdn, - grpc_schedule_on_exec_ctx); + fdn->already_shutdown = false; + GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable_locked, fdn, + grpc_combiner_scheduler(ev_driver->combiner)); + GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_locked, fdn, + grpc_combiner_scheduler(ev_driver->combiner)); grpc_pollset_set_add_fd(ev_driver->pollset_set, fdn->fd); gpr_free(fd_name); } fdn->next = new_list; new_list = fdn; - gpr_mu_lock(&fdn->mu); // Register read_closure if the socket is readable and read_closure has // not been registered with this socket. if (ARES_GETSOCK_READABLE(socks_bitmask, i) && @@ -319,7 +286,6 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) { grpc_fd_notify_on_write(fdn->fd, &fdn->write_closure); fdn->writable_registered = true; } - gpr_mu_unlock(&fdn->mu); } } } @@ -329,7 +295,13 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) { while (ev_driver->fds != nullptr) { fd_node* cur = ev_driver->fds; ev_driver->fds = ev_driver->fds->next; - fd_node_shutdown(cur); + fd_node_shutdown_locked(cur, "c-ares fd shutdown"); + if (!cur->readable_registered && !cur->writable_registered) { + fd_node_destroy_locked(cur); + } else { + cur->next = new_list; + new_list = cur; + } } ev_driver->fds = new_list; // If the ev driver has no working fd, all the tasks are done. @@ -339,13 +311,11 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) { } } -void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver) { - gpr_mu_lock(&ev_driver->mu); +void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) { if (!ev_driver->working) { ev_driver->working = true; grpc_ares_notify_on_event_locked(ev_driver); } - gpr_mu_unlock(&ev_driver->mu); } -#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 18d0a7b9f6..471de58e8c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -65,8 +65,6 @@ struct grpc_ares_request { /** number of ongoing queries */ gpr_refcount pending_queries; - /** mutex guarding the rest of the state */ - gpr_mu mu; /** is there at least one successful query, set in on_done_cb */ bool success; /** the errors explaining the request failure, set in on_done_cb */ @@ -74,7 +72,8 @@ struct grpc_ares_request { }; typedef struct grpc_ares_hostbyname_request { - /** following members are set in create_hostbyname_request */ + /** following members are set in create_hostbyname_request_locked + */ /** the top-level request instance */ grpc_ares_request* parent_request; /** host to resolve, parsed from the name to resolve */ @@ -96,10 +95,6 @@ static uint16_t strhtons(const char* port) { return htons(static_cast<unsigned short>(atoi(port))); } -static void grpc_ares_request_ref(grpc_ares_request* r) { - gpr_ref(&r->pending_queries); -} - static void log_address_sorting_list(grpc_lb_addresses* lb_addrs, const char* input_output_str) { for (size_t i = 0; i < lb_addrs->num_addresses; i++) { @@ -149,7 +144,11 @@ void grpc_cares_wrapper_test_only_address_sorting_sort( grpc_cares_wrapper_address_sorting_sort(lb_addrs); } -static void grpc_ares_request_unref(grpc_ares_request* r) { +static void grpc_ares_request_ref_locked(grpc_ares_request* r) { + gpr_ref(&r->pending_queries); +} + +static void grpc_ares_request_unref_locked(grpc_ares_request* r) { /* If there are no pending queries, invoke on_done callback and destroy the request */ if (gpr_unref(&r->pending_queries)) { @@ -158,13 +157,12 @@ static void grpc_ares_request_unref(grpc_ares_request* r) { grpc_cares_wrapper_address_sorting_sort(lb_addrs); } GRPC_CLOSURE_SCHED(r->on_done, r->error); - gpr_mu_destroy(&r->mu); - grpc_ares_ev_driver_destroy(r->ev_driver); + grpc_ares_ev_driver_destroy_locked(r->ev_driver); gpr_free(r); } } -static grpc_ares_hostbyname_request* create_hostbyname_request( +static grpc_ares_hostbyname_request* create_hostbyname_request_locked( grpc_ares_request* parent_request, char* host, uint16_t port, bool is_balancer) { grpc_ares_hostbyname_request* hr = static_cast<grpc_ares_hostbyname_request*>( @@ -173,22 +171,22 @@ static grpc_ares_hostbyname_request* create_hostbyname_request( hr->host = gpr_strdup(host); hr->port = port; hr->is_balancer = is_balancer; - grpc_ares_request_ref(parent_request); + grpc_ares_request_ref_locked(parent_request); return hr; } -static void destroy_hostbyname_request(grpc_ares_hostbyname_request* hr) { - grpc_ares_request_unref(hr->parent_request); +static void destroy_hostbyname_request_locked( + grpc_ares_hostbyname_request* hr) { + grpc_ares_request_unref_locked(hr->parent_request); gpr_free(hr->host); gpr_free(hr); } -static void on_hostbyname_done_cb(void* arg, int status, int timeouts, - struct hostent* hostent) { +static void on_hostbyname_done_locked(void* arg, int status, int timeouts, + struct hostent* hostent) { grpc_ares_hostbyname_request* hr = static_cast<grpc_ares_hostbyname_request*>(arg); grpc_ares_request* r = hr->parent_request; - gpr_mu_lock(&r->mu); if (status == ARES_SUCCESS) { GRPC_ERROR_UNREF(r->error); r->error = GRPC_ERROR_NONE; @@ -263,33 +261,33 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts, r->error = grpc_error_add_child(error, r->error); } } - gpr_mu_unlock(&r->mu); - destroy_hostbyname_request(hr); + destroy_hostbyname_request_locked(hr); } -static void on_srv_query_done_cb(void* arg, int status, int timeouts, - unsigned char* abuf, int alen) { +static void on_srv_query_done_locked(void* arg, int status, int timeouts, + unsigned char* abuf, int alen) { grpc_ares_request* r = static_cast<grpc_ares_request*>(arg); - gpr_log(GPR_DEBUG, "on_query_srv_done_cb"); + gpr_log(GPR_DEBUG, "on_query_srv_done_locked"); if (status == ARES_SUCCESS) { - gpr_log(GPR_DEBUG, "on_query_srv_done_cb ARES_SUCCESS"); + gpr_log(GPR_DEBUG, "on_query_srv_done_locked ARES_SUCCESS"); struct ares_srv_reply* reply; const int parse_status = ares_parse_srv_reply(abuf, alen, &reply); if (parse_status == ARES_SUCCESS) { - ares_channel* channel = grpc_ares_ev_driver_get_channel(r->ev_driver); + ares_channel* channel = + grpc_ares_ev_driver_get_channel_locked(r->ev_driver); for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr; srv_it = srv_it->next) { if (grpc_ipv6_loopback_available()) { - grpc_ares_hostbyname_request* hr = create_hostbyname_request( + grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked( r, srv_it->host, htons(srv_it->port), true /* is_balancer */); ares_gethostbyname(*channel, hr->host, AF_INET6, - on_hostbyname_done_cb, hr); + on_hostbyname_done_locked, hr); } - grpc_ares_hostbyname_request* hr = create_hostbyname_request( + grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked( r, srv_it->host, htons(srv_it->port), true /* is_balancer */); - ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb, - hr); - grpc_ares_ev_driver_start(r->ev_driver); + ares_gethostbyname(*channel, hr->host, AF_INET, + on_hostbyname_done_locked, hr); + grpc_ares_ev_driver_start_locked(r->ev_driver); } } if (reply != nullptr) { @@ -307,21 +305,20 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts, r->error = grpc_error_add_child(error, r->error); } } - grpc_ares_request_unref(r); + grpc_ares_request_unref_locked(r); } static const char g_service_config_attribute_prefix[] = "grpc_config="; -static void on_txt_done_cb(void* arg, int status, int timeouts, - unsigned char* buf, int len) { - gpr_log(GPR_DEBUG, "on_txt_done_cb"); +static void on_txt_done_locked(void* arg, int status, int timeouts, + unsigned char* buf, int len) { + gpr_log(GPR_DEBUG, "on_txt_done_locked"); char* error_msg; grpc_ares_request* r = static_cast<grpc_ares_request*>(arg); const size_t prefix_len = sizeof(g_service_config_attribute_prefix) - 1; struct ares_txt_ext* result = nullptr; struct ares_txt_ext* reply = nullptr; grpc_error* error = GRPC_ERROR_NONE; - gpr_mu_lock(&r->mu); if (status != ARES_SUCCESS) goto fail; status = ares_parse_txt_reply_ext(buf, len, &reply); if (status != ARES_SUCCESS) goto fail; @@ -366,14 +363,14 @@ fail: r->error = grpc_error_add_child(error, r->error); } done: - gpr_mu_unlock(&r->mu); - grpc_ares_request_unref(r); + grpc_ares_request_unref_locked(r); } -static grpc_ares_request* grpc_dns_lookup_ares_impl( +static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) { + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { grpc_error* error = GRPC_ERROR_NONE; grpc_ares_hostbyname_request* hr = nullptr; grpc_ares_request* r = nullptr; @@ -402,20 +399,19 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl( } port = gpr_strdup(default_port); } - grpc_ares_ev_driver* ev_driver; - error = grpc_ares_ev_driver_create(&ev_driver, interested_parties); + error = grpc_ares_ev_driver_create_locked(&ev_driver, interested_parties, + combiner); if (error != GRPC_ERROR_NONE) goto error_cleanup; r = static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request))); - gpr_mu_init(&r->mu); r->ev_driver = ev_driver; r->on_done = on_done; r->lb_addrs_out = addrs; r->service_config_json_out = service_config_json; r->success = false; r->error = GRPC_ERROR_NONE; - channel = grpc_ares_ev_driver_get_channel(r->ev_driver); + channel = grpc_ares_ev_driver_get_channel_locked(r->ev_driver); // If dns_server is specified, use it. if (dns_server != nullptr) { @@ -457,32 +453,34 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl( } gpr_ref_init(&r->pending_queries, 1); if (grpc_ipv6_loopback_available()) { - hr = create_hostbyname_request(r, host, strhtons(port), - false /* is_balancer */); - ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_cb, hr); + hr = create_hostbyname_request_locked(r, host, strhtons(port), + false /* is_balancer */); + ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked, + hr); } - hr = create_hostbyname_request(r, host, strhtons(port), - false /* is_balancer */); - ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb, hr); + hr = create_hostbyname_request_locked(r, host, strhtons(port), + false /* is_balancer */); + ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_locked, + hr); if (check_grpclb) { /* Query the SRV record */ - grpc_ares_request_ref(r); + grpc_ares_request_ref_locked(r); char* service_name; gpr_asprintf(&service_name, "_grpclb._tcp.%s", host); - ares_query(*channel, service_name, ns_c_in, ns_t_srv, on_srv_query_done_cb, - r); + ares_query(*channel, service_name, ns_c_in, ns_t_srv, + on_srv_query_done_locked, r); gpr_free(service_name); } if (service_config_json != nullptr) { - grpc_ares_request_ref(r); + grpc_ares_request_ref_locked(r); char* config_name; gpr_asprintf(&config_name, "_grpc_config.%s", host); - ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_cb, r); + ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_locked, + r); gpr_free(config_name); } - /* TODO(zyc): Handle CNAME records here. */ - grpc_ares_ev_driver_start(r->ev_driver); - grpc_ares_request_unref(r); + grpc_ares_ev_driver_start_locked(r->ev_driver); + grpc_ares_request_unref_locked(r); gpr_free(host); gpr_free(port); return r; @@ -494,15 +492,15 @@ error_cleanup: return nullptr; } -grpc_ares_request* (*grpc_dns_lookup_ares)( +grpc_ares_request* (*grpc_dns_lookup_ares_locked)( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, - char** service_config_json) = grpc_dns_lookup_ares_impl; + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl; void grpc_cancel_ares_request(grpc_ares_request* r) { - if (grpc_dns_lookup_ares == grpc_dns_lookup_ares_impl) { - grpc_ares_ev_driver_shutdown(r->ev_driver); + if (grpc_dns_lookup_ares_locked == grpc_dns_lookup_ares_locked_impl) { + grpc_ares_ev_driver_shutdown_locked(r->ev_driver); } } @@ -534,6 +532,8 @@ void grpc_ares_cleanup(void) { */ typedef struct grpc_resolve_address_ares_request { + /* combiner that queries and related callbacks run under */ + grpc_combiner* combiner; /** the pointer to receive the resolved addresses */ grpc_resolved_addresses** addrs_out; /** currently resolving lb addresses */ @@ -541,8 +541,14 @@ typedef struct grpc_resolve_address_ares_request { /** closure to call when the resolve_address_ares request completes */ grpc_closure* on_resolve_address_done; /** a closure wrapping on_dns_lookup_done_cb, which should be invoked when the - grpc_dns_lookup_ares operation is done. */ + grpc_dns_lookup_ares_locked operation is done. */ grpc_closure on_dns_lookup_done; + /* target name */ + const char* name; + /* default port to use if none is specified */ + const char* default_port; + /* pollset_set to be driven by */ + grpc_pollset_set* interested_parties; } grpc_resolve_address_ares_request; static void on_dns_lookup_done_cb(void* arg, grpc_error* error) { @@ -566,9 +572,20 @@ static void on_dns_lookup_done_cb(void* arg, grpc_error* error) { } GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error)); if (r->lb_addrs != nullptr) grpc_lb_addresses_destroy(r->lb_addrs); + GRPC_COMBINER_UNREF(r->combiner, "on_dns_lookup_done_cb"); gpr_free(r); } +static void grpc_resolve_address_invoke_dns_lookup_ares_locked( + void* arg, grpc_error* unused_error) { + grpc_resolve_address_ares_request* r = + static_cast<grpc_resolve_address_ares_request*>(arg); + grpc_dns_lookup_ares_locked( + nullptr /* dns_server */, r->name, r->default_port, r->interested_parties, + &r->on_dns_lookup_done, &r->lb_addrs, false /* check_grpclb */, + nullptr /* service_config_json */, r->combiner); +} + static void grpc_resolve_address_ares_impl(const char* name, const char* default_port, grpc_pollset_set* interested_parties, @@ -577,14 +594,18 @@ static void grpc_resolve_address_ares_impl(const char* name, grpc_resolve_address_ares_request* r = static_cast<grpc_resolve_address_ares_request*>( gpr_zalloc(sizeof(grpc_resolve_address_ares_request))); + r->combiner = grpc_combiner_create(); r->addrs_out = addrs; r->on_resolve_address_done = on_done; GRPC_CLOSURE_INIT(&r->on_dns_lookup_done, on_dns_lookup_done_cb, r, grpc_schedule_on_exec_ctx); - grpc_dns_lookup_ares(nullptr /* dns_server */, name, default_port, - interested_parties, &r->on_dns_lookup_done, &r->lb_addrs, - false /* check_grpclb */, - nullptr /* service_config_json */); + r->name = name; + r->default_port = default_port; + r->interested_parties = interested_parties; + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE(grpc_resolve_address_invoke_dns_lookup_ares_locked, r, + grpc_combiner_scheduler(r->combiner)), + GRPC_ERROR_NONE); } void (*grpc_resolve_address_ares)( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index 2d84a038d6..9e93d0cf94 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -48,11 +48,11 @@ extern void (*grpc_resolve_address_ares)(const char* name, function. \a on_done may be called directly in this function without being scheduled with \a exec_ctx, so it must not try to acquire locks that are being held by the caller. */ -extern grpc_ares_request* (*grpc_dns_lookup_ares)( +extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb, - char** service_config_json); + char** service_config_json, grpc_combiner* combiner); /* Cancel the pending grpc_ares_request \a request */ void grpc_cancel_ares_request(grpc_ares_request* request); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc index 5096e480bc..d6a76fc8b6 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc @@ -26,18 +26,19 @@ struct grpc_ares_request { char val; }; -static grpc_ares_request* grpc_dns_lookup_ares_impl( +static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) { + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { return NULL; } -grpc_ares_request* (*grpc_dns_lookup_ares)( +grpc_ares_request* (*grpc_dns_lookup_ares_locked)( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, - char** service_config_json) = grpc_dns_lookup_ares_impl; + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl; void grpc_cancel_ares_request(grpc_ares_request* r) {} diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index fae4c33a17..25e92a078d 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -116,10 +116,9 @@ NativeDnsResolver::NativeDnsResolver(const ResolverArgs& args) if (path[0] == '/') ++path; name_to_resolve_ = gpr_strdup(path); channel_args_ = grpc_channel_args_copy(args.args); - const grpc_arg* arg = grpc_channel_args_find( - args.args, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); - min_time_between_resolutions_ = - grpc_channel_arg_get_integer(arg, {1000, 0, INT_MAX}); + min_time_between_resolutions_ = grpc_channel_args_get_integer( + args.args, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS, + {1000, 0, INT_MAX}); interested_parties_ = grpc_pollset_set_create(); if (args.pollset_set != nullptr) { grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set); diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index 99a33f2277..9250dbd6b3 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -252,20 +252,15 @@ static const grpc_arg_pointer_vtable response_generator_arg_vtable = { grpc_arg FakeResolverResponseGenerator::MakeChannelArg( FakeResolverResponseGenerator* generator) { - grpc_arg arg; - arg.type = GRPC_ARG_POINTER; - arg.key = (char*)GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR; - arg.value.pointer.p = generator; - arg.value.pointer.vtable = &response_generator_arg_vtable; - return arg; + return grpc_channel_arg_pointer_create( + const_cast<char*>(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR), generator, + &response_generator_arg_vtable); } FakeResolverResponseGenerator* FakeResolverResponseGenerator::GetFromArgs( const grpc_channel_args* args) { - const grpc_arg* arg = - grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR); - if (arg == nullptr || arg->type != GRPC_ARG_POINTER) return nullptr; - return static_cast<FakeResolverResponseGenerator*>(arg->value.pointer.p); + return grpc_channel_args_get_pointer<FakeResolverResponseGenerator>( + args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR); } // diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index f010002ab9..5db5d1f6c0 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -736,9 +736,8 @@ void grpc_get_subchannel_address_arg(const grpc_channel_args* args, } const char* grpc_get_subchannel_address_uri_arg(const grpc_channel_args* args) { - const grpc_arg* addr_arg = - grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS); - const char* addr_str = grpc_channel_arg_get_string(addr_arg); + const char* addr_str = + grpc_channel_args_get_string(args, GRPC_ARG_SUBCHANNEL_ADDRESS); GPR_ASSERT(addr_str != nullptr); // Should have been set by LB policy. return addr_str; } diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index 27d3eac8d6..caa547204b 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -289,11 +289,10 @@ static void client_start_transport_stream_op_batch( static void recv_initial_metadata_ready(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast<grpc_call_element*>(arg); server_call_data* calld = static_cast<server_call_data*>(elem->call_data); - // Get deadline from metadata and start the timer if needed. start_timer_if_needed(elem, calld->recv_initial_metadata->deadline); // Invoke the next callback. - calld->next_recv_initial_metadata_ready->cb( - calld->next_recv_initial_metadata_ready->cb_arg, error); + GRPC_CLOSURE_RUN(calld->next_recv_initial_metadata_ready, + GRPC_ERROR_REF(error)); } // Method for starting a call op for server filter. @@ -359,8 +358,8 @@ const grpc_channel_filter grpc_server_deadline_filter = { }; bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) { - return grpc_channel_arg_get_bool( - grpc_channel_args_find(channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS), + return grpc_channel_args_get_bool( + channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS, !grpc_channel_args_want_minimal_stack(channel_args)); } diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index ae94ce47b9..fe7f2ba705 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -23,6 +23,7 @@ #include <stdint.h> #include <string.h> #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/profiling/timers.h" @@ -435,64 +436,43 @@ static void destroy_call_elem(grpc_call_element* elem, const grpc_call_final_info* final_info, grpc_closure* ignored) {} -static grpc_mdelem scheme_from_args(const grpc_channel_args* args) { - unsigned i; - size_t j; +static grpc_mdelem scheme_from_args(const grpc_channel_args* channel_args) { grpc_mdelem valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_SCHEME_HTTPS}; - if (args != nullptr) { - for (i = 0; i < args->num_args; ++i) { - if (args->args[i].type == GRPC_ARG_STRING && - strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) { - for (j = 0; j < GPR_ARRAY_SIZE(valid_schemes); j++) { - if (0 == grpc_slice_str_cmp(GRPC_MDVALUE(valid_schemes[j]), - args->args[i].value.string)) { - return valid_schemes[j]; - } - } + char* scheme = + grpc_channel_args_get_string(channel_args, GRPC_ARG_HTTP2_SCHEME); + if (scheme != nullptr) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(valid_schemes); i++) { + if (0 == grpc_slice_str_cmp(GRPC_MDVALUE(valid_schemes[i]), scheme)) { + return valid_schemes[i]; } } } return GRPC_MDELEM_SCHEME_HTTP; } -static size_t max_payload_size_from_args(const grpc_channel_args* args) { - if (args != nullptr) { - for (size_t i = 0; i < args->num_args; ++i) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET)) { - if (args->args[i].type != GRPC_ARG_INTEGER) { - gpr_log(GPR_ERROR, "%s: must be an integer", - GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET); - } else { - return static_cast<size_t>(args->args[i].value.integer); - } - } - } - } - return kMaxPayloadSizeForGet; +static size_t max_payload_size_from_args( + const grpc_channel_args* channel_args) { + return grpc_channel_args_get_integer( + channel_args, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET, + {kMaxPayloadSizeForGet, 0, kMaxPayloadSizeForGet}); } static grpc_slice user_agent_from_args(const grpc_channel_args* args, const char* transport_name) { gpr_strvec v; - size_t i; int is_first = 1; char* tmp; grpc_slice result; gpr_strvec_init(&v); - for (i = 0; args && i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_PRIMARY_USER_AGENT_STRING)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", - GRPC_ARG_PRIMARY_USER_AGENT_STRING); - } else { - if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); - is_first = 0; - gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); - } - } + char* user_agent_str = + grpc_channel_args_get_string(args, GRPC_ARG_PRIMARY_USER_AGENT_STRING); + if (user_agent_str != nullptr) { + if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); + is_first = 0; + gpr_strvec_add(&v, gpr_strdup(user_agent_str)); } gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s; %s)", is_first ? "" : " ", @@ -501,17 +481,11 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args, is_first = 0; gpr_strvec_add(&v, tmp); - for (i = 0; args && i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_SECONDARY_USER_AGENT_STRING)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", - GRPC_ARG_SECONDARY_USER_AGENT_STRING); - } else { - if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); - is_first = 0; - gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); - } - } + user_agent_str = + grpc_channel_args_get_string(args, GRPC_ARG_SECONDARY_USER_AGENT_STRING); + if (user_agent_str != nullptr) { + gpr_strvec_add(&v, gpr_strdup(" ")); + gpr_strvec_add(&v, gpr_strdup(user_agent_str)); } tmp = gpr_strvec_flatten(&v, nullptr); diff --git a/src/core/ext/filters/http/http_filters_plugin.cc b/src/core/ext/filters/http/http_filters_plugin.cc index f03fa0141d..d3cbe50016 100644 --- a/src/core/ext/filters/http/http_filters_plugin.cc +++ b/src/core/ext/filters/http/http_filters_plugin.cc @@ -48,8 +48,8 @@ static bool maybe_add_optional_filter(grpc_channel_stack_builder* builder, optional_filter* filtarg = static_cast<optional_filter*>(arg); const grpc_channel_args* channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); - bool enable = grpc_channel_arg_get_bool( - grpc_channel_args_find(channel_args, filtarg->control_channel_arg), + bool enable = grpc_channel_args_get_bool( + channel_args, filtarg->control_channel_arg, !grpc_channel_args_want_minimal_stack(channel_args)); return enable ? grpc_channel_stack_builder_prepend_filter( builder, filtarg->filter, nullptr, nullptr) diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index 0d349e2a89..a8f70333b2 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -82,9 +82,7 @@ static void on_initial_md_ready(void* user_data, grpc_error* err) { } else { GRPC_ERROR_REF(err); } - calld->ops_recv_initial_metadata_ready->cb( - calld->ops_recv_initial_metadata_ready->cb_arg, err); - GRPC_ERROR_UNREF(err); + GRPC_CLOSURE_RUN(calld->ops_recv_initial_metadata_ready, err); } /* Constructor for call_data */ diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc index 667c0c56ef..73bcf242d8 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc @@ -33,8 +33,7 @@ #include "src/core/lib/surface/channel_init.h" static bool is_load_reporting_enabled(const grpc_channel_args* a) { - return grpc_channel_arg_get_bool( - grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false); + return grpc_channel_args_get_bool(a, GRPC_ARG_ENABLE_LOAD_REPORTING, false); } static bool maybe_add_server_load_reporting_filter( diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index 1fe8288bd0..bbe4998f00 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -519,13 +519,12 @@ static bool maybe_add_max_age_filter(grpc_channel_stack_builder* builder, void* arg) { const grpc_channel_args* channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); - bool enable = - grpc_channel_arg_get_integer( - grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS), - MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX || - grpc_channel_arg_get_integer( - grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS), - MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX; + bool enable = grpc_channel_args_get_integer( + channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS, + MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX || + grpc_channel_args_get_integer( + channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS, + MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX; if (enable) { return grpc_channel_stack_builder_prepend_filter( builder, &grpc_max_age_filter, nullptr, nullptr); diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index c7fc3f2e62..9815c93145 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -254,9 +254,8 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, channel_data* chand = static_cast<channel_data*>(elem->channel_data); chand->limits = get_message_size_limits(args->channel_args); // Get method config table from channel args. - const grpc_arg* channel_arg = - grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); - const char* service_config_str = grpc_channel_arg_get_string(channel_arg); + const char* service_config_str = + grpc_channel_args_get_string(args->channel_args, GRPC_ARG_SERVICE_CONFIG); if (service_config_str != nullptr) { grpc_core::UniquePtr<grpc_core::ServiceConfig> service_config = grpc_core::ServiceConfig::Create(service_config_str); diff --git a/src/core/ext/transport/chttp2/client/authority.cc b/src/core/ext/transport/chttp2/client/authority.cc index bad3153b01..e3ef47c199 100644 --- a/src/core/ext/transport/chttp2/client/authority.cc +++ b/src/core/ext/transport/chttp2/client/authority.cc @@ -28,9 +28,8 @@ grpc_channel_args* grpc_default_authority_add_if_not_present( size_t num_new_args = 0; grpc_core::UniquePtr<char> default_authority; if (!has_default_authority) { - const grpc_arg* server_uri_arg = - grpc_channel_args_find(args, GRPC_ARG_SERVER_URI); - const char* server_uri_str = grpc_channel_arg_get_string(server_uri_arg); + const char* server_uri_str = + grpc_channel_args_get_string(args, GRPC_ARG_SERVER_URI); GPR_ASSERT(server_uri_str != nullptr); default_authority = grpc_core::ResolverRegistry::GetDefaultAuthority(server_uri_str); diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc index b95c9dae53..dfed824cd5 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -50,7 +50,7 @@ grpc_channel* grpc_insecure_channel_create_from_fd( GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); grpc_endpoint* client = grpc_tcp_client_create_from_fd( - grpc_fd_create(fd, "client"), args, "fd-client"); + grpc_fd_create(fd, "client", false), args, "fd-client"); grpc_transport* transport = grpc_create_chttp2_transport(final_args, client, true); diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index 5ce73a95d7..f49bd27b6c 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -64,9 +64,8 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args( return nullptr; } // To which address are we connecting? By default, use the server URI. - const grpc_arg* server_uri_arg = - grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI); - const char* server_uri_str = grpc_channel_arg_get_string(server_uri_arg); + const char* server_uri_str = + grpc_channel_args_get_string(args->args, GRPC_ARG_SERVER_URI); GPR_ASSERT(server_uri_str != nullptr); grpc_uri* server_uri = grpc_uri_parse(server_uri_str, true /* supress errors */); diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc index 371e463814..a0228785ee 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc @@ -43,8 +43,9 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server, char* name; gpr_asprintf(&name, "fd:%d", fd); - grpc_endpoint* server_endpoint = grpc_tcp_create( - grpc_fd_create(fd, name), grpc_server_get_channel_args(server), name); + grpc_endpoint* server_endpoint = + grpc_tcp_create(grpc_fd_create(fd, name, false), + grpc_server_get_channel_args(server), name); gpr_free(name); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index cc4a823798..1a924e66e6 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -447,20 +447,19 @@ static void init_transport(grpc_chttp2_transport* t, grpc_channel_arg_get_integer(&channel_args->args[i], {0, 0, 1})); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_OPTIMIZATION_TARGET)) { - if (channel_args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "%s should be a string", - GRPC_ARG_OPTIMIZATION_TARGET); - } else if (0 == strcmp(channel_args->args[i].value.string, "blend")) { + char* opt_target_str = + grpc_channel_arg_get_string(&channel_args->args[i]); + if (opt_target_str == nullptr) { + gpr_log(GPR_ERROR, "null/missing value opt target, assuming 'blend'"); + } else if (0 == strcmp(opt_target_str, "blend")) { t->opt_target = GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY; - } else if (0 == strcmp(channel_args->args[i].value.string, "latency")) { + } else if (0 == strcmp(opt_target_str, "latency")) { t->opt_target = GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY; - } else if (0 == - strcmp(channel_args->args[i].value.string, "throughput")) { + } else if (0 == strcmp(opt_target_str, "throughput")) { t->opt_target = GRPC_CHTTP2_OPTIMIZE_FOR_THROUGHPUT; } else { gpr_log(GPR_ERROR, "%s value '%s' unknown, assuming 'blend'", - GRPC_ARG_OPTIMIZATION_TARGET, - channel_args->args[i].value.string); + GRPC_ARG_OPTIMIZATION_TARGET, opt_target_str); } } else { static const struct { @@ -1451,10 +1450,8 @@ static void perform_stream_op_locked(void* stream_op, } } if (op_payload->send_initial_metadata.peer_string != nullptr) { - char* old_peer_string = (char*)gpr_atm_full_xchg( - op_payload->send_initial_metadata.peer_string, - (gpr_atm)gpr_strdup(t->peer_string)); - gpr_free(old_peer_string); + gpr_atm_rel_store(op_payload->send_initial_metadata.peer_string, + (gpr_atm)t->peer_string); } } @@ -1569,10 +1566,8 @@ static void perform_stream_op_locked(void* stream_op, s->trailing_metadata_available = op_payload->recv_initial_metadata.trailing_metadata_available; if (op_payload->recv_initial_metadata.peer_string != nullptr) { - char* old_peer_string = (char*)gpr_atm_full_xchg( - op_payload->recv_initial_metadata.peer_string, - (gpr_atm)gpr_strdup(t->peer_string)); - gpr_free(old_peer_string); + gpr_atm_rel_store(op_payload->recv_initial_metadata.peer_string, + (gpr_atm)t->peer_string); } grpc_chttp2_maybe_complete_recv_initial_metadata(t, s); } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 420c2d13e1..5d614c1d05 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -1450,20 +1450,8 @@ grpc_transport* grpc_create_cronet_transport(void* engine, const char* target, } strcpy(ct->host, target); - ct->use_packet_coalescing = true; - if (args) { - for (size_t i = 0; i < args->num_args; i++) { - if (0 == - strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) { - if (GPR_UNLIKELY(args->args[i].type != GRPC_ARG_INTEGER)) { - gpr_log(GPR_ERROR, "%s ignored: it must be an integer", - GRPC_ARG_USE_CRONET_PACKET_COALESCING); - } else { - ct->use_packet_coalescing = (args->args[i].value.integer != 0); - } - } - } - } + ct->use_packet_coalescing = grpc_channel_args_get_bool( + args, GRPC_ARG_USE_CRONET_PACKET_COALESCING, true); return &ct->base; diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 2c3bff5c1e..6e5aa5a46b 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -1204,10 +1204,9 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, // Add a default authority channel argument for the client - grpc_arg default_authority_arg; - default_authority_arg.type = GRPC_ARG_STRING; - default_authority_arg.key = (char*)GRPC_ARG_DEFAULT_AUTHORITY; - default_authority_arg.value.string = (char*)"inproc.authority"; + grpc_arg default_authority_arg = grpc_channel_arg_string_create( + const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY), + const_cast<char*>("inproc.authority")); grpc_channel_args* client_args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 5ff303a9dc..0c4f56a688 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -23,6 +23,7 @@ #include <grpc/compression.h> #include <grpc/grpc.h> +#include <grpc/support/log.h> #include "src/core/lib/iomgr/socket_mutator.h" // Channel args are intentionally immutable, to avoid the need for locking. @@ -110,13 +111,49 @@ typedef struct grpc_integer_options { /** Returns the value of \a arg, subject to the contraints in \a options. */ int grpc_channel_arg_get_integer(const grpc_arg* arg, const grpc_integer_options options); +/** convinience helper for the above that finds the arg first. */ +inline int grpc_channel_args_get_integer(const grpc_channel_args* args, + const char* name, + const grpc_integer_options options) { + return grpc_channel_arg_get_integer(grpc_channel_args_find(args, name), + options); +} /** Returns the value of \a arg if \a arg is of type GRPC_ARG_STRING. Otherwise, emits a warning log, and returns nullptr. If arg is nullptr, returns nullptr, and does not emit a warning. */ char* grpc_channel_arg_get_string(const grpc_arg* arg); +/** convinience helper for the above that finds the arg first. */ +inline char* grpc_channel_args_get_string(const grpc_channel_args* args, + const char* name) { + return grpc_channel_arg_get_string(grpc_channel_args_find(args, name)); +} + +/** Returns the value of \a arg if \a arg is of type GRPC_ARG_POINTER + Otherwise, emits a warning log, and returns nullptr. + If arg is nullptr, returns nullptr, and does not emit a warning. */ +template <typename Type> +inline Type* grpc_channel_arg_get_pointer(const grpc_arg* arg) { + if (arg == nullptr) return nullptr; + if (arg->type != GRPC_ARG_POINTER) { + gpr_log(GPR_ERROR, "%s ignored: it must be an pointer", arg->key); + return nullptr; + } + return static_cast<Type*>(arg->value.pointer.p); +} +/** convinience helper for the above that finds the arg first. */ +template <typename Type> +inline Type* grpc_channel_args_get_pointer(const grpc_channel_args* args, + const char* name) { + return grpc_channel_arg_get_pointer<Type>(grpc_channel_args_find(args, name)); +} bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value); +inline bool grpc_channel_args_get_bool(const grpc_channel_args* args, + const char* name, bool default_value) { + return grpc_channel_arg_get_bool(grpc_channel_args_find(args, name), + default_value); +} // Helpers for creating channel args. grpc_arg grpc_channel_arg_string_create(char* name, char* value); diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc index 86f8699e04..ad3250b7e9 100644 --- a/src/core/lib/channel/handshaker.cc +++ b/src/core/lib/channel/handshaker.cc @@ -223,18 +223,23 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr, mgr->index == mgr->count) { if (error == GRPC_ERROR_NONE && mgr->shutdown) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("handshaker shutdown"); - // TODO(roth): It is currently necessary to shutdown endpoints - // before destroying then, even when we know that there are no - // pending read/write callbacks. This should be fixed, at which - // point this can be removed. - grpc_endpoint_shutdown(mgr->args.endpoint, GRPC_ERROR_REF(error)); - grpc_endpoint_destroy(mgr->args.endpoint); - mgr->args.endpoint = nullptr; - grpc_channel_args_destroy(mgr->args.args); - mgr->args.args = nullptr; - grpc_slice_buffer_destroy_internal(mgr->args.read_buffer); - gpr_free(mgr->args.read_buffer); - mgr->args.read_buffer = nullptr; + // It is possible that the endpoint has already been destroyed by + // a shutdown call while this callback was sitting on the ExecCtx + // with no error. + if (mgr->args.endpoint != nullptr) { + // TODO(roth): It is currently necessary to shutdown endpoints + // before destroying then, even when we know that there are no + // pending read/write callbacks. This should be fixed, at which + // point this can be removed. + grpc_endpoint_shutdown(mgr->args.endpoint, GRPC_ERROR_REF(error)); + grpc_endpoint_destroy(mgr->args.endpoint); + mgr->args.endpoint = nullptr; + grpc_channel_args_destroy(mgr->args.args); + mgr->args.args = nullptr; + grpc_slice_buffer_destroy_internal(mgr->args.read_buffer); + gpr_free(mgr->args.read_buffer); + mgr->args.read_buffer = nullptr; + } } if (grpc_handshaker_trace.enabled()) { gpr_log(GPR_INFO, diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc new file mode 100644 index 0000000000..827fd24831 --- /dev/null +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -0,0 +1,185 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <grpc/support/port_platform.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM +#import <CoreFoundation/CoreFoundation.h> +#import "src/core/lib/iomgr/cfstream_handle.h" + +#include <grpc/support/atm.h> +#include <grpc/support/sync.h> + +#include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/exec_ctx.h" + +extern grpc_core::TraceFlag grpc_tcp_trace; + +void* CFStreamHandle::Retain(void* info) { + CFStreamHandle* handle = static_cast<CFStreamHandle*>(info); + CFSTREAM_HANDLE_REF(handle, "retain"); + return info; +} + +void CFStreamHandle::Release(void* info) { + CFStreamHandle* handle = static_cast<CFStreamHandle*>(info); + CFSTREAM_HANDLE_UNREF(handle, "release"); +} + +CFStreamHandle* CFStreamHandle::CreateStreamHandle( + CFReadStreamRef read_stream, CFWriteStreamRef write_stream) { + return new CFStreamHandle(read_stream, write_stream); +} + +void CFStreamHandle::ReadCallback(CFReadStreamRef stream, + CFStreamEventType type, + void* client_callback_info) { + CFStreamHandle* handle = static_cast<CFStreamHandle*>(client_callback_info); + CFSTREAM_HANDLE_REF(handle, "read callback"); + dispatch_async( + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + grpc_core::ExecCtx exec_ctx; + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream ReadCallback (%p, %p, %lu, %p)", handle, + stream, type, client_callback_info); + } + switch (type) { + case kCFStreamEventOpenCompleted: + handle->open_event_.SetReady(); + break; + case kCFStreamEventHasBytesAvailable: + case kCFStreamEventEndEncountered: + handle->read_event_.SetReady(); + break; + case kCFStreamEventErrorOccurred: + handle->open_event_.SetReady(); + handle->read_event_.SetReady(); + break; + default: + GPR_UNREACHABLE_CODE(return ); + } + CFSTREAM_HANDLE_UNREF(handle, "read callback"); + }); +} +void CFStreamHandle::WriteCallback(CFWriteStreamRef stream, + CFStreamEventType type, + void* clientCallBackInfo) { + CFStreamHandle* handle = static_cast<CFStreamHandle*>(clientCallBackInfo); + CFSTREAM_HANDLE_REF(handle, "write callback"); + dispatch_async( + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + grpc_core::ExecCtx exec_ctx; + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream WriteCallback (%p, %p, %lu, %p)", handle, + stream, type, clientCallBackInfo); + } + switch (type) { + case kCFStreamEventOpenCompleted: + handle->open_event_.SetReady(); + break; + case kCFStreamEventCanAcceptBytes: + case kCFStreamEventEndEncountered: + handle->write_event_.SetReady(); + break; + case kCFStreamEventErrorOccurred: + handle->open_event_.SetReady(); + handle->write_event_.SetReady(); + break; + default: + GPR_UNREACHABLE_CODE(return ); + } + CFSTREAM_HANDLE_UNREF(handle, "write callback"); + }); +} + +CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream, + CFWriteStreamRef write_stream) { + gpr_ref_init(&refcount_, 1); + open_event_.InitEvent(); + read_event_.InitEvent(); + write_event_.InitEvent(); + CFStreamClientContext ctx = {0, static_cast<void*>(this), + CFStreamHandle::Retain, CFStreamHandle::Release, + nil}; + CFReadStreamSetClient( + read_stream, + kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable | + kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered, + CFStreamHandle::ReadCallback, &ctx); + CFWriteStreamSetClient( + write_stream, + kCFStreamEventOpenCompleted | kCFStreamEventCanAcceptBytes | + kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered, + CFStreamHandle::WriteCallback, &ctx); + CFReadStreamScheduleWithRunLoop(read_stream, CFRunLoopGetMain(), + kCFRunLoopCommonModes); + CFWriteStreamScheduleWithRunLoop(write_stream, CFRunLoopGetMain(), + kCFRunLoopCommonModes); +} + +CFStreamHandle::~CFStreamHandle() { + open_event_.DestroyEvent(); + read_event_.DestroyEvent(); + write_event_.DestroyEvent(); +} + +void CFStreamHandle::NotifyOnOpen(grpc_closure* closure) { + open_event_.NotifyOn(closure); +} + +void CFStreamHandle::NotifyOnRead(grpc_closure* closure) { + read_event_.NotifyOn(closure); +} + +void CFStreamHandle::NotifyOnWrite(grpc_closure* closure) { + write_event_.NotifyOn(closure); +} + +void CFStreamHandle::Shutdown(grpc_error* error) { + open_event_.SetShutdown(GRPC_ERROR_REF(error)); + read_event_.SetShutdown(GRPC_ERROR_REF(error)); + write_event_.SetShutdown(GRPC_ERROR_REF(error)); + GRPC_ERROR_UNREF(error); +} + +void CFStreamHandle::Ref(const char* file, int line, const char* reason) { + if (grpc_tcp_trace.enabled()) { + gpr_atm val = gpr_atm_no_barrier_load(&refcount_.count); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "CFStream Handle ref %p : %s %" PRIdPTR " -> %" PRIdPTR, this, + reason, val, val + 1); + } + gpr_ref(&refcount_); +} + +void CFStreamHandle::Unref(const char* file, int line, const char* reason) { + if (grpc_tcp_trace.enabled()) { + gpr_atm val = gpr_atm_no_barrier_load(&refcount_.count); + gpr_log(GPR_ERROR, + "CFStream Handle unref %p : %s %" PRIdPTR " -> %" PRIdPTR, this, + reason, val, val - 1); + } + if (gpr_unref(&refcount_)) { + delete this; + } +} + +#endif diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h new file mode 100644 index 0000000000..4258e72431 --- /dev/null +++ b/src/core/lib/iomgr/cfstream_handle.h @@ -0,0 +1,80 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* The CFStream handle acts as an event synchronization entity for + * read/write/open/error/eos events happening on CFStream streams. */ + +#ifndef GRPC_CORE_LIB_IOMGR_CFSTREAM_HANDLE_H +#define GRPC_CORE_LIB_IOMGR_CFSTREAM_HANDLE_H + +#include <grpc/support/port_platform.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM +#import <CoreFoundation/CoreFoundation.h> + +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/lockfree_event.h" + +class CFStreamHandle final { + public: + static CFStreamHandle* CreateStreamHandle(CFReadStreamRef read_stream, + CFWriteStreamRef write_stream); + ~CFStreamHandle(); + CFStreamHandle(const CFReadStreamRef& ref) = delete; + CFStreamHandle(CFReadStreamRef&& ref) = delete; + CFStreamHandle& operator=(const CFStreamHandle& rhs) = delete; + + void NotifyOnOpen(grpc_closure* closure); + void NotifyOnRead(grpc_closure* closure); + void NotifyOnWrite(grpc_closure* closure); + void Shutdown(grpc_error* error); + + void Ref(const char* file = "", int line = 0, const char* reason = nullptr); + void Unref(const char* file = "", int line = 0, const char* reason = nullptr); + + private: + CFStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream); + static void ReadCallback(CFReadStreamRef stream, CFStreamEventType type, + void* client_callback_info); + static void WriteCallback(CFWriteStreamRef stream, CFStreamEventType type, + void* client_callback_info); + static void* Retain(void* info); + static void Release(void* info); + + grpc_core::LockfreeEvent open_event_; + grpc_core::LockfreeEvent read_event_; + grpc_core::LockfreeEvent write_event_; + + gpr_refcount refcount_; +}; + +#ifdef DEBUG +#define CFSTREAM_HANDLE_REF(handle, reason) \ + (handle)->Ref(__FILE__, __LINE__, (reason)) +#define CFSTREAM_HANDLE_UNREF(handle, reason) \ + (handle)->Unref(__FILE__, __LINE__, (reason)) +#else +#define CFSTREAM_HANDLE_REF(handle, reason) (handle)->Ref() +#define CFSTREAM_HANDLE_UNREF(handle, reason) (handle)->Unref() +#endif + +#endif + +#endif /* GRPC_CORE_LIB_IOMGR_CFSTREAM_HANDLE_H */ diff --git a/src/core/lib/iomgr/endpoint_cfstream.cc b/src/core/lib/iomgr/endpoint_cfstream.cc new file mode 100644 index 0000000000..c3bc0cc8fd --- /dev/null +++ b/src/core/lib/iomgr/endpoint_cfstream.cc @@ -0,0 +1,372 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <grpc/support/port_platform.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM_ENDPOINT + +#import <CoreFoundation/CoreFoundation.h> +#import "src/core/lib/iomgr/endpoint_cfstream.h" + +#include <grpc/slice_buffer.h> +#include <grpc/support/alloc.h> +#include <grpc/support/string_util.h> + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/cfstream_handle.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/error_cfstream.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" + +extern grpc_core::TraceFlag grpc_tcp_trace; + +typedef struct { + grpc_endpoint base; + gpr_refcount refcount; + + CFReadStreamRef read_stream; + CFWriteStreamRef write_stream; + CFStreamHandle* stream_sync; + + grpc_closure* read_cb; + grpc_closure* write_cb; + grpc_slice_buffer* read_slices; + grpc_slice_buffer* write_slices; + + grpc_closure read_action; + grpc_closure write_action; + + char* peer_string; + grpc_resource_user* resource_user; + grpc_resource_user_slice_allocator slice_allocator; +} CFStreamEndpoint; + +static void CFStreamFree(CFStreamEndpoint* ep) { + grpc_resource_user_unref(ep->resource_user); + CFRelease(ep->read_stream); + CFRelease(ep->write_stream); + CFSTREAM_HANDLE_UNREF(ep->stream_sync, "free"); + gpr_free(ep->peer_string); + gpr_free(ep); +} + +#ifndef NDEBUG +#define EP_REF(ep, reason) CFStreamRef((ep), (reason), __FILE__, __LINE__) +#define EP_UNREF(ep, reason) CFStreamUnref((ep), (reason), __FILE__, __LINE__) +static void CFStreamUnref(CFStreamEndpoint* ep, const char* reason, + const char* file, int line) { + if (grpc_tcp_trace.enabled()) { + gpr_atm val = gpr_atm_no_barrier_load(&ep->refcount.count); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "CFStream endpoint unref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, + reason, val, val - 1); + } + if (gpr_unref(&ep->refcount)) { + CFStreamFree(ep); + } +} +static void CFStreamRef(CFStreamEndpoint* ep, const char* reason, + const char* file, int line) { + if (grpc_tcp_trace.enabled()) { + gpr_atm val = gpr_atm_no_barrier_load(&ep->refcount.count); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "CFStream endpoint ref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, + reason, val, val + 1); + } + gpr_ref(&ep->refcount); +} +#else +#define EP_REF(ep, reason) CFStreamRef((ep)) +#define EP_UNREF(ep, reason) CFStreamUnref((ep)) +static void CFStreamUnref(CFStreamEndpoint* ep) { + if (gpr_unref(&ep->refcount)) { + CFStreamFree(ep); + } +} +static void CFStreamRef(CFStreamEndpoint* ep) { gpr_ref(&ep->refcount); } +#endif + +static grpc_error* CFStreamAnnotateError(grpc_error* src_error, + CFStreamEndpoint* ep) { + return grpc_error_set_str( + grpc_error_set_int(src_error, GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_UNAVAILABLE), + GRPC_ERROR_STR_TARGET_ADDRESS, + grpc_slice_from_copied_string(ep->peer_string)); +} + +static void CallReadCb(CFStreamEndpoint* ep, grpc_error* error) { + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p call_read_cb %p %p:%p", ep, + ep->read_cb, ep->read_cb->cb, ep->read_cb->cb_arg); + size_t i; + const char* str = grpc_error_string(error); + gpr_log(GPR_DEBUG, "read: error=%s", str); + + for (i = 0; i < ep->read_slices->count; i++) { + char* dump = grpc_dump_slice(ep->read_slices->slices[i], + GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", ep, ep->peer_string, dump); + gpr_free(dump); + } + } + grpc_closure* cb = ep->read_cb; + ep->read_cb = nullptr; + ep->read_slices = nullptr; + GRPC_CLOSURE_SCHED(cb, error); +} + +static void CallWriteCb(CFStreamEndpoint* ep, grpc_error* error) { + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p call_write_cb %p %p:%p", ep, + ep->write_cb, ep->write_cb->cb, ep->write_cb->cb_arg); + const char* str = grpc_error_string(error); + gpr_log(GPR_DEBUG, "write: error=%s", str); + } + grpc_closure* cb = ep->write_cb; + ep->write_cb = nullptr; + ep->write_slices = nullptr; + GRPC_CLOSURE_SCHED(cb, error); +} + +static void ReadAction(void* arg, grpc_error* error) { + CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg); + GPR_ASSERT(ep->read_cb != nullptr); + if (error) { + grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); + CallReadCb(ep, GRPC_ERROR_REF(error)); + EP_UNREF(ep, "read"); + return; + } + + GPR_ASSERT(ep->read_slices->count == 1); + grpc_slice slice = ep->read_slices->slices[0]; + size_t len = GRPC_SLICE_LENGTH(slice); + CFIndex read_size = + CFReadStreamRead(ep->read_stream, GRPC_SLICE_START_PTR(slice), len); + if (read_size == -1) { + grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); + CFErrorRef stream_error = CFReadStreamCopyError(ep->read_stream); + if (stream_error != nullptr) { + error = CFStreamAnnotateError( + GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "Read error"), ep); + CFRelease(stream_error); + } else { + error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Read error"); + } + CallReadCb(ep, error); + EP_UNREF(ep, "read"); + } else if (read_size == 0) { + grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); + CallReadCb(ep, + CFStreamAnnotateError( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), ep)); + EP_UNREF(ep, "read"); + } else { + if (read_size < len) { + grpc_slice_buffer_trim_end(ep->read_slices, len - read_size, nullptr); + } + CallReadCb(ep, GRPC_ERROR_NONE); + EP_UNREF(ep, "read"); + } +} + +static void WriteAction(void* arg, grpc_error* error) { + CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg); + GPR_ASSERT(ep->write_cb != nullptr); + if (error) { + grpc_slice_buffer_reset_and_unref_internal(ep->write_slices); + CallWriteCb(ep, GRPC_ERROR_REF(error)); + EP_UNREF(ep, "write"); + return; + } + + grpc_slice slice = grpc_slice_buffer_take_first(ep->write_slices); + size_t slice_len = GRPC_SLICE_LENGTH(slice); + CFIndex write_size = CFWriteStreamWrite( + ep->write_stream, GRPC_SLICE_START_PTR(slice), slice_len); + if (write_size == -1) { + grpc_slice_buffer_reset_and_unref_internal(ep->write_slices); + CFErrorRef stream_error = CFWriteStreamCopyError(ep->write_stream); + if (stream_error != nullptr) { + error = CFStreamAnnotateError( + GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "write failed."), ep); + CFRelease(stream_error); + } else { + error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("write failed."); + } + CallWriteCb(ep, error); + EP_UNREF(ep, "write"); + } else { + if (write_size < GRPC_SLICE_LENGTH(slice)) { + grpc_slice_buffer_undo_take_first( + ep->write_slices, grpc_slice_sub(slice, write_size, slice_len)); + } + if (ep->write_slices->length > 0) { + ep->stream_sync->NotifyOnWrite(&ep->write_action); + } else { + CallWriteCb(ep, GRPC_ERROR_NONE); + EP_UNREF(ep, "write"); + } + + if (grpc_tcp_trace.enabled()) { + grpc_slice trace_slice = grpc_slice_sub(slice, 0, write_size); + char* dump = grpc_dump_slice(trace_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", ep, ep->peer_string, dump); + gpr_free(dump); + grpc_slice_unref_internal(trace_slice); + } + } + grpc_slice_unref_internal(slice); +} + +static void CFStreamReadAllocationDone(void* arg, grpc_error* error) { + CFStreamEndpoint* ep = static_cast<CFStreamEndpoint*>(arg); + if (error == GRPC_ERROR_NONE) { + ep->stream_sync->NotifyOnRead(&ep->read_action); + } else { + grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); + CallReadCb(ep, error); + EP_UNREF(ep, "read"); + } +} + +static void CFStreamRead(grpc_endpoint* ep, grpc_slice_buffer* slices, + grpc_closure* cb) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p read (%p, %p) length:%zu", ep_impl, + slices, cb, slices->length); + } + GPR_ASSERT(ep_impl->read_cb == nullptr); + ep_impl->read_cb = cb; + ep_impl->read_slices = slices; + grpc_slice_buffer_reset_and_unref_internal(slices); + grpc_resource_user_alloc_slices(&ep_impl->slice_allocator, + GRPC_TCP_DEFAULT_READ_SLICE_SIZE, 1, + ep_impl->read_slices); + EP_REF(ep_impl, "read"); +} + +static void CFStreamWrite(grpc_endpoint* ep, grpc_slice_buffer* slices, + grpc_closure* cb) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p write (%p, %p) length:%zu", + ep_impl, slices, cb, slices->length); + } + GPR_ASSERT(ep_impl->write_cb == nullptr); + ep_impl->write_cb = cb; + ep_impl->write_slices = slices; + EP_REF(ep_impl, "write"); + ep_impl->stream_sync->NotifyOnWrite(&ep_impl->write_action); +} + +void CFStreamShutdown(grpc_endpoint* ep, grpc_error* why) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown (%p)", ep_impl, why); + } + CFReadStreamClose(ep_impl->read_stream); + CFWriteStreamClose(ep_impl->write_stream); + ep_impl->stream_sync->Shutdown(why); + grpc_resource_user_shutdown(ep_impl->resource_user); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown DONE (%p)", ep_impl, why); + } +} + +void CFStreamDestroy(grpc_endpoint* ep) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CFStream endpoint:%p destroy", ep_impl); + } + EP_UNREF(ep_impl, "destroy"); +} + +grpc_resource_user* CFStreamGetResourceUser(grpc_endpoint* ep) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + return ep_impl->resource_user; +} + +char* CFStreamGetPeer(grpc_endpoint* ep) { + CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep); + return gpr_strdup(ep_impl->peer_string); +} + +int CFStreamGetFD(grpc_endpoint* ep) { return 0; } + +void CFStreamAddToPollset(grpc_endpoint* ep, grpc_pollset* pollset) {} +void CFStreamAddToPollsetSet(grpc_endpoint* ep, grpc_pollset_set* pollset) {} +void CFStreamDeleteFromPollsetSet(grpc_endpoint* ep, + grpc_pollset_set* pollset) {} + +static const grpc_endpoint_vtable vtable = {CFStreamRead, + CFStreamWrite, + CFStreamAddToPollset, + CFStreamAddToPollsetSet, + CFStreamDeleteFromPollsetSet, + CFStreamShutdown, + CFStreamDestroy, + CFStreamGetResourceUser, + CFStreamGetPeer, + CFStreamGetFD}; + +grpc_endpoint* grpc_cfstream_endpoint_create( + CFReadStreamRef read_stream, CFWriteStreamRef write_stream, + const char* peer_string, grpc_resource_quota* resource_quota, + CFStreamHandle* stream_sync) { + CFStreamEndpoint* ep_impl = + static_cast<CFStreamEndpoint*>(gpr_malloc(sizeof(CFStreamEndpoint))); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, + "CFStream endpoint:%p create readStream:%p writeStream: %p", + ep_impl, read_stream, write_stream); + } + ep_impl->base.vtable = &vtable; + gpr_ref_init(&ep_impl->refcount, 1); + ep_impl->read_stream = read_stream; + ep_impl->write_stream = write_stream; + CFRetain(read_stream); + CFRetain(write_stream); + ep_impl->stream_sync = stream_sync; + CFSTREAM_HANDLE_REF(ep_impl->stream_sync, "endpoint create"); + + ep_impl->peer_string = gpr_strdup(peer_string); + ep_impl->read_cb = nil; + ep_impl->write_cb = nil; + ep_impl->read_slices = nil; + ep_impl->write_slices = nil; + GRPC_CLOSURE_INIT(&ep_impl->read_action, ReadAction, + static_cast<void*>(ep_impl), grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&ep_impl->write_action, WriteAction, + static_cast<void*>(ep_impl), grpc_schedule_on_exec_ctx); + ep_impl->resource_user = + grpc_resource_user_create(resource_quota, peer_string); + grpc_resource_user_slice_allocator_init(&ep_impl->slice_allocator, + ep_impl->resource_user, + CFStreamReadAllocationDone, ep_impl); + + return &ep_impl->base; +} + +#endif /* GRPC_CFSTREAM_ENDPOINT */ diff --git a/src/core/lib/iomgr/endpoint_cfstream.h b/src/core/lib/iomgr/endpoint_cfstream.h new file mode 100644 index 0000000000..ef957c1f11 --- /dev/null +++ b/src/core/lib/iomgr/endpoint_cfstream.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ENDPOINT_CFSTREAM_H +#define GRPC_CORE_LIB_IOMGR_ENDPOINT_CFSTREAM_H +/* + Low level TCP "bottom half" implementation, for use by transports built on + top of a TCP connection. + + Note that this file does not (yet) include APIs for creating the socket in + the first place. + + All calls passing slice transfer ownership of a slice refcount unless + otherwise specified. +*/ + +#include <grpc/support/port_platform.h> + +#ifdef GRPC_CFSTREAM + +#import <CoreFoundation/CoreFoundation.h> + +#include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/cfstream_handle.h" +#include "src/core/lib/iomgr/endpoint.h" + +grpc_endpoint* grpc_cfstream_endpoint_create( + CFReadStreamRef read_stream, CFWriteStreamRef write_stream, + const char* peer_string, grpc_resource_quota* resource_quota, + CFStreamHandle* stream_sync); + +#endif /* GRPC_CFSTREAM */ + +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_CFSTREAM_H */ diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc index 49850ab3a1..5c5c246f99 100644 --- a/src/core/lib/iomgr/endpoint_pair_posix.cc +++ b/src/core/lib/iomgr/endpoint_pair_posix.cc @@ -59,11 +59,11 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name, grpc_core::ExecCtx exec_ctx; gpr_asprintf(&final_name, "%s:client", name); - p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name), args, + p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name, false), args, "socketpair-server"); gpr_free(final_name); gpr_asprintf(&final_name, "%s:server", name); - p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name), args, + p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name, false), args, "socketpair-client"); gpr_free(final_name); diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index 4088cf612e..90ed34da11 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -312,6 +312,12 @@ static void internal_add_error(grpc_error** err, grpc_error* new_err) { // It is very common to include and extra int and string in an error #define SURPLUS_CAPACITY (2 * SLOTS_PER_INT + SLOTS_PER_TIME) +static bool g_error_creation_allowed = true; + +void grpc_disable_error_creation() { g_error_creation_allowed = false; } + +void grpc_enable_error_creation() { g_error_creation_allowed = true; } + grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc, grpc_error** referencing, size_t num_referencing) { @@ -326,6 +332,12 @@ grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc, return GRPC_ERROR_OOM; } #ifndef NDEBUG + if (!g_error_creation_allowed) { + gpr_log(GPR_ERROR, + "Error creation occurred when error creation was disabled [%s:%d]", + file, line); + abort(); + } if (grpc_trace_error_refcount.enabled()) { gpr_log(GPR_DEBUG, "%p create [%s:%d]", err, file, line); } diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index f8cae4da82..27c4d22fd1 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -123,6 +123,11 @@ typedef enum { #define GRPC_ERROR_OOM ((grpc_error*)2) #define GRPC_ERROR_CANCELLED ((grpc_error*)4) +// debug only toggles that allow for a sanity to check that ensures we will +// never create any errors in the per-RPC hotpath. +void grpc_disable_error_creation(); +void grpc_enable_error_creation(); + const char* grpc_error_string(grpc_error* error); /// Create an error - but use GRPC_ERROR_CREATE instead diff --git a/src/core/lib/iomgr/error_cfstream.cc b/src/core/lib/iomgr/error_cfstream.cc new file mode 100644 index 0000000000..d7af8c377f --- /dev/null +++ b/src/core/lib/iomgr/error_cfstream.cc @@ -0,0 +1,52 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <grpc/support/port_platform.h> + +#ifdef GRPC_CFSTREAM +#include <CoreFoundation/CoreFoundation.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/string_util.h> + +#include "src/core/lib/iomgr/error.h" + +#define MAX_ERROR_DESCRIPTION 256 + +grpc_error* grpc_error_create_from_cferror(const char* file, int line, + void* arg, const char* custom_desc) { + CFErrorRef error = static_cast<CFErrorRef>(arg); + char buf_domain[MAX_ERROR_DESCRIPTION]; + char buf_desc[MAX_ERROR_DESCRIPTION]; + char* error_msg; + CFErrorDomain domain = CFErrorGetDomain((error)); + CFIndex code = CFErrorGetCode((error)); + CFStringRef desc = CFErrorCopyDescription((error)); + CFStringGetCString(domain, buf_domain, MAX_ERROR_DESCRIPTION, + kCFStringEncodingUTF8); + CFStringGetCString(desc, buf_desc, MAX_ERROR_DESCRIPTION, + kCFStringEncodingUTF8); + gpr_asprintf(&error_msg, "%s (error domain:%s, code:%ld, description:%s)", + custom_desc, buf_domain, code, buf_desc); + CFRelease(desc); + grpc_error* return_error = grpc_error_create( + file, line, grpc_slice_from_copied_string(error_msg), NULL, 0); + gpr_free(error_msg); + return return_error; +} +#endif /* GRPC_CFSTREAM */ diff --git a/src/core/lib/iomgr/error_cfstream.h b/src/core/lib/iomgr/error_cfstream.h new file mode 100644 index 0000000000..06ab751329 --- /dev/null +++ b/src/core/lib/iomgr/error_cfstream.h @@ -0,0 +1,31 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H +#define GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H + +#ifdef GRPC_CFSTREAM +// Create an error from Apple Core Foundation CFError object +#define GRPC_ERROR_CREATE_FROM_CFERROR(error, desc) \ + grpc_error_create_from_cferror(__FILE__, __LINE__, \ + static_cast<void*>((error)), (desc)) +grpc_error* grpc_error_create_from_cferror(const char* file, int line, + void* arg, const char* desc); +#endif /* GRPC_CFSTREAM */ + +#endif /* GRPC_CORE_LIB_IOMGR_ERROR_CFSTREAM_H */ diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index e5db1be0e0..86a0243d2e 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -136,6 +136,7 @@ struct grpc_fd { grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure; grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure; + grpc_core::ManualConstructor<grpc_core::LockfreeEvent> error_closure; struct grpc_fd* freelist_next; @@ -272,7 +273,7 @@ static void fd_global_shutdown(void) { gpr_mu_destroy(&fd_freelist_mu); } -static grpc_fd* fd_create(int fd, const char* name) { +static grpc_fd* fd_create(int fd, const char* name, bool track_err) { grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); @@ -286,11 +287,12 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd = static_cast<grpc_fd*>(gpr_malloc(sizeof(grpc_fd))); new_fd->read_closure.Init(); new_fd->write_closure.Init(); + new_fd->error_closure.Init(); } - new_fd->fd = fd; new_fd->read_closure->InitEvent(); new_fd->write_closure->InitEvent(); + new_fd->error_closure->InitEvent(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); new_fd->freelist_next = nullptr; @@ -307,7 +309,13 @@ static grpc_fd* fd_create(int fd, const char* name) { struct epoll_event ev; ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLOUT | EPOLLET); - ev.data.ptr = new_fd; + /* Use the least significant bit of ev.data.ptr to store track_err. We expect + * the addresses to be word aligned. We need to store track_err to avoid + * synchronization issues when accessing it after receiving an event. + * Accessing fd would be a data race there because the fd might have been + * returned to the free list at that point. */ + ev.data.ptr = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(new_fd) | + (track_err ? 1 : 0)); if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_ADD, fd, &ev) != 0) { gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno)); } @@ -327,6 +335,7 @@ static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why, shutdown(fd->fd, SHUT_RDWR); } fd->write_closure->SetShutdown(GRPC_ERROR_REF(why)); + fd->error_closure->SetShutdown(GRPC_ERROR_REF(why)); } GRPC_ERROR_UNREF(why); } @@ -337,7 +346,7 @@ static void fd_shutdown(grpc_fd* fd, grpc_error* why) { } static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason) { + const char* reason) { grpc_error* error = GRPC_ERROR_NONE; bool is_release_fd = (release_fd != nullptr); @@ -350,7 +359,7 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, descriptor fd->fd (but we still own the grpc_fd structure). */ if (is_release_fd) { *release_fd = fd->fd; - } else if (!already_closed) { + } else { close(fd->fd); } @@ -359,6 +368,7 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, grpc_iomgr_unregister_object(&fd->iomgr_object); fd->read_closure->DestroyEvent(); fd->write_closure->DestroyEvent(); + fd->error_closure->DestroyEvent(); gpr_mu_lock(&fd_freelist_mu); fd->freelist_next = fd_freelist; @@ -383,6 +393,10 @@ static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { fd->write_closure->NotifyOn(closure); } +static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { + fd->error_closure->NotifyOn(closure); +} + static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { fd->read_closure->SetReady(); /* Use release store to match with acquire load in fd_get_read_notifier */ @@ -391,6 +405,8 @@ static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } +static void fd_has_errors(grpc_fd* fd) { fd->error_closure->SetReady(); } + /******************************************************************************* * Pollset Definitions */ @@ -611,16 +627,25 @@ static grpc_error* process_epoll_events(grpc_pollset* pollset) { append_error(&error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd), err_desc); } else { - grpc_fd* fd = static_cast<grpc_fd*>(data_ptr); - bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0; + grpc_fd* fd = reinterpret_cast<grpc_fd*>( + reinterpret_cast<intptr_t>(data_ptr) & ~static_cast<intptr_t>(1)); + bool track_err = + reinterpret_cast<intptr_t>(data_ptr) & static_cast<intptr_t>(1); + bool cancel = (ev->events & EPOLLHUP) != 0; + bool error = (ev->events & EPOLLERR) != 0; bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0; bool write_ev = (ev->events & EPOLLOUT) != 0; + bool err_fallback = error && !track_err; + + if (error && !err_fallback) { + fd_has_errors(fd); + } - if (read_ev || cancel) { + if (read_ev || cancel || err_fallback) { fd_become_readable(fd, pollset); } - if (write_ev || cancel) { + if (write_ev || cancel || err_fallback) { fd_become_writable(fd); } } @@ -1183,6 +1208,7 @@ static void shutdown_engine(void) { static const grpc_event_engine_vtable vtable = { sizeof(grpc_pollset), + true, fd_create, fd_wrapped_fd, @@ -1190,6 +1216,7 @@ static const grpc_event_engine_vtable vtable = { fd_shutdown, fd_notify_on_read, fd_notify_on_write, + fd_notify_on_error, fd_is_shutdown, fd_get_read_notifier_pollset, @@ -1237,12 +1264,12 @@ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { } #else /* defined(GRPC_LINUX_EPOLL) */ -#if defined(GRPC_POSIX_SOCKET) +#if defined(GRPC_POSIX_SOCKET_EV_EPOLL1) #include "src/core/lib/iomgr/ev_epoll1_linux.h" /* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return * NULL */ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { return nullptr; } -#endif /* defined(GRPC_POSIX_SOCKET) */ +#endif /* defined(GRPC_POSIX_SOCKET_EV_EPOLL1) */ #endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 12f23ea1d6..55a2b98372 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -63,7 +63,7 @@ // a keepalive ping timeout issue. We may want to revert https://github // .com/grpc/grpc/pull/14943 once we figure out the root cause. #define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 16 -#define MAX_PROBE_EPOLL_FDS 32 +#define MAX_FDS_IN_CACHE 32 grpc_core::DebugOnlyTraceFlag grpc_trace_pollable_refcount(false, "pollable_refcount"); @@ -77,8 +77,14 @@ typedef enum { PO_MULTI, PO_FD, PO_EMPTY } pollable_type; typedef struct pollable pollable; typedef struct cached_fd { + // Set to the grpc_fd's salt value. See 'salt' variable' in grpc_fd for more + // details intptr_t salt; + + // The underlying fd int fd; + + // A recency time counter that helps to determine the LRU fd in the cache uint64_t last_used; } cached_fd; @@ -111,10 +117,32 @@ struct pollable { int event_count; struct epoll_event events[MAX_EPOLL_EVENTS]; - // Maintain a LRU-eviction cache of fds in this pollable - cached_fd fd_cache[MAX_PROBE_EPOLL_FDS]; + // We may be calling pollable_add_fd() on the same (pollable, fd) multiple + // times. To prevent pollable_add_fd() from making multiple sys calls to + // epoll_ctl() to add the fd, we maintain a cache of what fds are already + // present in the underlying epoll-set. + // + // Since this is not a correctness issue, we do not need to maintain all the + // fds in the cache. Hence we just use an LRU cache of size 'MAX_FDS_IN_CACHE' + // + // NOTE: An ideal implementation of this should do the following: + // 1) Add fds to the cache in pollable_add_fd() function (i.e whenever the fd + // is added to the pollable's epoll set) + // 2) Remove the fd from the cache whenever the fd is removed from the + // underlying epoll set (i.e whenever fd_orphan() is called). + // + // Implementing (2) above (i.e removing fds from cache on fd_orphan) adds a + // lot of complexity since an fd can be present in multiple pollalbles. So our + // implementation ONLY DOES (1) and NOT (2). + // + // The cache_fd.salt variable helps here to maintain correctness (it serves as + // an epoch that differentiates one grpc_fd from the other even though both of + // them may have the same fd number) + // + // The following implements LRU-eviction cache of fds in this pollable + cached_fd fd_cache[MAX_FDS_IN_CACHE]; int fd_cache_size; - uint64_t fd_cache_counter; + uint64_t fd_cache_counter; // Recency timer tick counter }; static const char* pollable_type_string(pollable_type t) { @@ -157,15 +185,24 @@ static void pollable_unref(pollable* p, int line, const char* reason); * Fd Declarations */ +// Monotonically increasing Epoch counter that is assinged to each grpc_fd. See +// the description of 'salt' variable in 'grpc_fd' for more details +// TODO: (sreek/kpayson) gpr_atm is intptr_t which may not be wide-enough on +// 32-bit systems. Change this to int_64 - atleast on 32-bit systems static gpr_atm g_fd_salt; struct grpc_fd { int fd; + + // Since fd numbers can be reused (after old fds are closed), this serves as + // an epoch that uniquely identifies this fd (i.e the pair (salt, fd) is + // unique (until the salt counter (i.e g_fd_salt) overflows) intptr_t salt; - /* refst format: - bit 0 : 1=Active / 0=Orphaned - bits 1-n : refcount - Ref/Unref by two to avoid altering the orphaned bit */ + + // refst format: + // bit 0 : 1=Active / 0=Orphaned + // bits 1-n : refcount + // Ref/Unref by two to avoid altering the orphaned bit gpr_atm refst; gpr_mu orphan_mu; @@ -175,15 +212,19 @@ struct grpc_fd { grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure; grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure; + grpc_core::ManualConstructor<grpc_core::LockfreeEvent> error_closure; struct grpc_fd* freelist_next; grpc_closure* on_done_closure; - /* The pollset that last noticed that the fd is readable. The actual type - * stored in this is (grpc_pollset *) */ + // The pollset that last noticed that the fd is readable. The actual type + // stored in this is (grpc_pollset *) gpr_atm read_notifier_pollset; grpc_iomgr_object iomgr_object; + + // Do we need to track EPOLLERR events separately? + bool track_err; }; static void fd_global_init(void); @@ -309,6 +350,7 @@ static void fd_destroy(void* arg, grpc_error* error) { fd->read_closure->DestroyEvent(); fd->write_closure->DestroyEvent(); + fd->error_closure->DestroyEvent(); gpr_mu_unlock(&fd_freelist_mu); } @@ -348,7 +390,7 @@ static void fd_global_shutdown(void) { gpr_mu_destroy(&fd_freelist_mu); } -static grpc_fd* fd_create(int fd, const char* name) { +static grpc_fd* fd_create(int fd, const char* name, bool track_err) { grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); @@ -362,6 +404,7 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd = static_cast<grpc_fd*>(gpr_malloc(sizeof(grpc_fd))); new_fd->read_closure.Init(); new_fd->write_closure.Init(); + new_fd->error_closure.Init(); } gpr_mu_init(&new_fd->pollable_mu); @@ -369,9 +412,11 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd->pollable_obj = nullptr; gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1); new_fd->fd = fd; + new_fd->track_err = track_err; new_fd->salt = gpr_atm_no_barrier_fetch_add(&g_fd_salt, 1); new_fd->read_closure->InitEvent(); new_fd->write_closure->InitEvent(); + new_fd->error_closure->InitEvent(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); new_fd->freelist_next = nullptr; @@ -395,8 +440,8 @@ static int fd_wrapped_fd(grpc_fd* fd) { } static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason) { - bool is_fd_closed = already_closed; + const char* reason) { + bool is_fd_closed = false; gpr_mu_lock(&fd->orphan_mu); @@ -406,7 +451,7 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, descriptor fd->fd (but we still own the grpc_fd structure). */ if (release_fd != nullptr) { *release_fd = fd->fd; - } else if (!is_fd_closed) { + } else { close(fd->fd); is_fd_closed = true; } @@ -438,8 +483,14 @@ static bool fd_is_shutdown(grpc_fd* fd) { /* Might be called multiple times */ static void fd_shutdown(grpc_fd* fd, grpc_error* why) { if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) { - shutdown(fd->fd, SHUT_RDWR); + if (shutdown(fd->fd, SHUT_RDWR)) { + if (errno != ENOTCONN) { + gpr_log(GPR_ERROR, "Error shutting down fd %d. errno: %d", + grpc_fd_wrapped_fd(fd), errno); + } + } fd->write_closure->SetShutdown(GRPC_ERROR_REF(why)); + fd->error_closure->SetShutdown(GRPC_ERROR_REF(why)); } GRPC_ERROR_UNREF(why); } @@ -452,6 +503,10 @@ static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { fd->write_closure->NotifyOn(closure); } +static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { + fd->error_closure->NotifyOn(closure); +} + /******************************************************************************* * Pollable Definitions */ @@ -544,6 +599,7 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { const int epfd = p->epfd; gpr_mu_lock(&p->mu); p->fd_cache_counter++; + // Handle the case of overflow for our cache counter by // reseting the recency-counter on all cache objects if (p->fd_cache_counter == 0) { @@ -563,8 +619,9 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { lru_idx = i; } } + // Add to cache - if (p->fd_cache_size < MAX_PROBE_EPOLL_FDS) { + if (p->fd_cache_size < MAX_FDS_IN_CACHE) { lru_idx = p->fd_cache_size; p->fd_cache_size++; } @@ -572,6 +629,7 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { p->fd_cache[lru_idx].salt = fd->salt; p->fd_cache[lru_idx].last_used = p->fd_cache_counter; gpr_mu_unlock(&p->mu); + if (grpc_polling_trace.enabled()) { gpr_log(GPR_INFO, "add fd %p (%d) to pollable %p", fd, fd->fd, p); } @@ -579,7 +637,12 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { struct epoll_event ev_fd; ev_fd.events = static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE); - ev_fd.data.ptr = fd; + /* Use the second least significant bit of ev_fd.data.ptr to store track_err + * to avoid synchronization issues when accessing it after receiving an event. + * Accessing fd would be a data race there because the fd might have been + * returned to the free list at that point. */ + ev_fd.data.ptr = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(fd) | + (fd->track_err ? 2 : 0)); GRPC_STATS_INC_SYSCALL_EPOLL_CTL(); if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd->fd, &ev_fd) != 0) { switch (errno) { @@ -780,6 +843,8 @@ static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } +static void fd_has_errors(grpc_fd* fd) { fd->error_closure->SetReady(); } + static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) { gpr_mu_lock(&fd->pollable_mu); grpc_error* error = GRPC_ERROR_NONE; @@ -848,20 +913,28 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset, (intptr_t)data_ptr)), err_desc); } else { - grpc_fd* fd = static_cast<grpc_fd*>(data_ptr); - bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0; + grpc_fd* fd = + reinterpret_cast<grpc_fd*>(reinterpret_cast<intptr_t>(data_ptr) & ~2); + bool track_err = reinterpret_cast<intptr_t>(data_ptr) & 2; + bool cancel = (ev->events & EPOLLHUP) != 0; + bool error = (ev->events & EPOLLERR) != 0; bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0; bool write_ev = (ev->events & EPOLLOUT) != 0; + bool err_fallback = error && !track_err; + if (grpc_polling_trace.enabled()) { gpr_log(GPR_INFO, "PS:%p got fd %p: cancel=%d read=%d " "write=%d", pollset, fd, cancel, read_ev, write_ev); } - if (read_ev || cancel) { + if (error && !err_fallback) { + fd_has_errors(fd); + } + if (read_ev || cancel || err_fallback) { fd_become_readable(fd, pollset); } - if (write_ev || cancel) { + if (write_ev || cancel || err_fallback) { fd_become_writable(fd); } } @@ -1503,6 +1576,7 @@ static void shutdown_engine(void) { static const grpc_event_engine_vtable vtable = { sizeof(grpc_pollset), + true, fd_create, fd_wrapped_fd, @@ -1510,6 +1584,7 @@ static const grpc_event_engine_vtable vtable = { fd_shutdown, fd_notify_on_read, fd_notify_on_write, + fd_notify_on_error, fd_is_shutdown, fd_get_read_notifier_pollset, @@ -1556,7 +1631,7 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux( } #else /* defined(GRPC_LINUX_EPOLL_CREATE1) */ -#if defined(GRPC_POSIX_SOCKET) +#if defined(GRPC_POSIX_SOCKET_EV_EPOLLEX) #include "src/core/lib/iomgr/ev_epollex_linux.h" /* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means epoll_create1 is not available. Return NULL */ @@ -1564,6 +1639,6 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux( bool explicitly_requested) { return nullptr; } -#endif /* defined(GRPC_POSIX_SOCKET) */ +#endif /* defined(GRPC_POSIX_SOCKET_EV_EPOLLEX) */ #endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */ diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 494bc71c1d..2189801c18 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -132,6 +132,7 @@ struct grpc_fd { grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure; grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure; + grpc_core::ManualConstructor<grpc_core::LockfreeEvent> error_closure; struct grpc_fd* freelist_next; grpc_closure* on_done_closure; @@ -141,6 +142,9 @@ struct grpc_fd { gpr_atm read_notifier_pollset; grpc_iomgr_object iomgr_object; + + /* Do we need to track EPOLLERR events separately? */ + bool track_err; }; /* Reference counting for fds */ @@ -352,7 +356,10 @@ static void polling_island_add_fds_locked(polling_island* pi, grpc_fd** fds, for (i = 0; i < fd_count; i++) { ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLOUT | EPOLLET); - ev.data.ptr = fds[i]; + /* Use the least significant bit of ev.data.ptr to store track_err to avoid + * synchronization issues when accessing it after receiving an event */ + ev.data.ptr = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(fds[i]) | + (fds[i]->track_err ? 1 : 0)); err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_ADD, fds[i]->fd, &ev); if (err < 0) { @@ -435,7 +442,6 @@ static void polling_island_remove_all_fds_locked(polling_island* pi, /* The caller is expected to hold pi->mu lock before calling this function */ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd, - bool is_fd_closed, grpc_error** error) { int err; size_t i; @@ -444,16 +450,14 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd, /* If fd is already closed, then it would have been automatically been removed from the epoll set */ - if (!is_fd_closed) { - err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr); - if (err < 0 && errno != ENOENT) { - gpr_asprintf( - &err_msg, - "epoll_ctl (epoll_fd: %d) del fd: %d failed with error: %d (%s)", - pi->epoll_fd, fd->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); - gpr_free(err_msg); - } + err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr); + if (err < 0 && errno != ENOENT) { + gpr_asprintf( + &err_msg, + "epoll_ctl (epoll_fd: %d) del fd: %d failed with error: %d (%s)", + pi->epoll_fd, fd->fd, errno, strerror(errno)); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + gpr_free(err_msg); } for (i = 0; i < pi->fd_cnt; i++) { @@ -769,6 +773,7 @@ static void unref_by(grpc_fd* fd, int n) { fd->read_closure->DestroyEvent(); fd->write_closure->DestroyEvent(); + fd->error_closure->DestroyEvent(); gpr_mu_unlock(&fd_freelist_mu); } else { @@ -806,7 +811,7 @@ static void fd_global_shutdown(void) { gpr_mu_destroy(&fd_freelist_mu); } -static grpc_fd* fd_create(int fd, const char* name) { +static grpc_fd* fd_create(int fd, const char* name, bool track_err) { grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); @@ -821,6 +826,7 @@ static grpc_fd* fd_create(int fd, const char* name) { gpr_mu_init(&new_fd->po.mu); new_fd->read_closure.Init(); new_fd->write_closure.Init(); + new_fd->error_closure.Init(); } /* Note: It is not really needed to get the new_fd->po.mu lock here. If this @@ -837,6 +843,8 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd->orphaned = false; new_fd->read_closure->InitEvent(); new_fd->write_closure->InitEvent(); + new_fd->error_closure->InitEvent(); + new_fd->track_err = track_err; gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); new_fd->freelist_next = nullptr; @@ -863,7 +871,7 @@ static int fd_wrapped_fd(grpc_fd* fd) { } static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason) { + const char* reason) { grpc_error* error = GRPC_ERROR_NONE; polling_island* unref_pi = nullptr; @@ -884,7 +892,7 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, before doing this.) */ if (fd->po.pi != nullptr) { polling_island* pi_latest = polling_island_lock(fd->po.pi); - polling_island_remove_fd_locked(pi_latest, fd, already_closed, &error); + polling_island_remove_fd_locked(pi_latest, fd, &error); gpr_mu_unlock(&pi_latest->mu); unref_pi = fd->po.pi; @@ -933,6 +941,7 @@ static void fd_shutdown(grpc_fd* fd, grpc_error* why) { if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) { shutdown(fd->fd, SHUT_RDWR); fd->write_closure->SetShutdown(GRPC_ERROR_REF(why)); + fd->error_closure->SetShutdown(GRPC_ERROR_REF(why)); } GRPC_ERROR_UNREF(why); } @@ -945,6 +954,10 @@ static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { fd->write_closure->NotifyOn(closure); } +static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { + fd->error_closure->NotifyOn(closure); +} + /******************************************************************************* * Pollset Definitions */ @@ -1116,6 +1129,8 @@ static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } +static void fd_has_errors(grpc_fd* fd) { fd->error_closure->SetReady(); } + static void pollset_release_polling_island(grpc_pollset* ps, const char* reason) { if (ps->po.pi != nullptr) { @@ -1254,14 +1269,23 @@ static void pollset_work_and_unlock(grpc_pollset* pollset, to the function pollset_work_and_unlock() will pick up the correct epoll_fd */ } else { - grpc_fd* fd = static_cast<grpc_fd*>(data_ptr); - int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP); - int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI); - int write_ev = ep_ev[i].events & EPOLLOUT; - if (read_ev || cancel) { + grpc_fd* fd = reinterpret_cast<grpc_fd*>( + reinterpret_cast<intptr_t>(data_ptr) & ~static_cast<intptr_t>(1)); + bool track_err = + reinterpret_cast<intptr_t>(data_ptr) & ~static_cast<intptr_t>(1); + bool cancel = (ep_ev[i].events & EPOLLHUP) != 0; + bool error = (ep_ev[i].events & EPOLLERR) != 0; + bool read_ev = (ep_ev[i].events & (EPOLLIN | EPOLLPRI)) != 0; + bool write_ev = (ep_ev[i].events & EPOLLOUT) != 0; + bool err_fallback = error && !track_err; + + if (error && !err_fallback) { + fd_has_errors(fd); + } + if (read_ev || cancel || err_fallback) { fd_become_readable(fd, pollset); } - if (write_ev || cancel) { + if (write_ev || cancel || err_fallback) { fd_become_writable(fd); } } @@ -1634,6 +1658,7 @@ static void shutdown_engine(void) { static const grpc_event_engine_vtable vtable = { sizeof(grpc_pollset), + true, fd_create, fd_wrapped_fd, @@ -1641,6 +1666,7 @@ static const grpc_event_engine_vtable vtable = { fd_shutdown, fd_notify_on_read, fd_notify_on_write, + fd_notify_on_error, fd_is_shutdown, fd_get_read_notifier_pollset, @@ -1721,7 +1747,7 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux( } #else /* defined(GRPC_LINUX_EPOLL_CREATE1) */ -#if defined(GRPC_POSIX_SOCKET) +#if defined(GRPC_POSIX_SOCKET_EV_EPOLLSIG) #include "src/core/lib/iomgr/ev_epollsig_linux.h" /* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means epoll_create1 is not available. Return NULL */ diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 504787e659..c9c09881a2 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV_POLL #include "src/core/lib/iomgr/ev_poll_posix.h" @@ -330,7 +330,8 @@ static void unref_by(grpc_fd* fd, int n) { } } -static grpc_fd* fd_create(int fd, const char* name) { +static grpc_fd* fd_create(int fd, const char* name, bool track_err) { + GPR_DEBUG_ASSERT(track_err == false); grpc_fd* r = static_cast<grpc_fd*>(gpr_malloc(sizeof(*r))); gpr_mu_init(&r->mu); gpr_atm_rel_store(&r->refst, 1); @@ -424,14 +425,12 @@ static int fd_wrapped_fd(grpc_fd* fd) { } static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason) { + const char* reason) { fd->on_done_closure = on_done; fd->released = release_fd != nullptr; if (release_fd != nullptr) { *release_fd = fd->fd; fd->released = true; - } else if (already_closed) { - fd->released = true; } gpr_mu_lock(&fd->mu); REF_BY(fd, 1, reason); /* remove active status, but keep referenced */ @@ -553,6 +552,11 @@ static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { gpr_mu_unlock(&fd->mu); } +static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { + gpr_log(GPR_ERROR, "Polling engine does not support tracking errors."); + abort(); +} + static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, grpc_pollset_worker* worker, uint32_t read_mask, uint32_t write_mask, grpc_fd_watcher* watcher) { @@ -1710,6 +1714,7 @@ static void shutdown_engine(void) { static const grpc_event_engine_vtable vtable = { sizeof(grpc_pollset), + false, fd_create, fd_wrapped_fd, @@ -1717,6 +1722,7 @@ static const grpc_event_engine_vtable vtable = { fd_shutdown, fd_notify_on_read, fd_notify_on_write, + fd_notify_on_error, fd_is_shutdown, fd_get_read_notifier_pollset, @@ -1761,4 +1767,4 @@ const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request) { return &vtable; } -#endif +#endif /* GRPC_POSIX_SOCKET_EV_POLL */ diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 902dca934a..1139b3273a 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include "src/core/lib/iomgr/ev_posix.h" @@ -193,10 +193,15 @@ void grpc_event_engine_shutdown(void) { g_event_engine = nullptr; } -grpc_fd* grpc_fd_create(int fd, const char* name) { - GRPC_POLLING_API_TRACE("fd_create(%d, %s)", fd, name); - GRPC_FD_TRACE("fd_create(%d, %s)", fd, name); - return g_event_engine->fd_create(fd, name); +bool grpc_event_engine_can_track_errors(void) { + return g_event_engine->can_track_err; +} + +grpc_fd* grpc_fd_create(int fd, const char* name, bool track_err) { + GRPC_POLLING_API_TRACE("fd_create(%d, %s, %d)", fd, name, track_err); + GRPC_FD_TRACE("fd_create(%d, %s, %d)", fd, name, track_err); + GPR_DEBUG_ASSERT(!track_err || g_event_engine->can_track_err); + return g_event_engine->fd_create(fd, name, track_err); } int grpc_fd_wrapped_fd(grpc_fd* fd) { @@ -204,13 +209,12 @@ int grpc_fd_wrapped_fd(grpc_fd* fd) { } void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason) { - GRPC_POLLING_API_TRACE("fd_orphan(%d, %p, %p, %d, %s)", - grpc_fd_wrapped_fd(fd), on_done, release_fd, - already_closed, reason); + const char* reason) { + GRPC_POLLING_API_TRACE("fd_orphan(%d, %p, %p, %s)", grpc_fd_wrapped_fd(fd), + on_done, release_fd, reason); GRPC_FD_TRACE("grpc_fd_orphan, fd:%d closed", grpc_fd_wrapped_fd(fd)); - g_event_engine->fd_orphan(fd, on_done, release_fd, already_closed, reason); + g_event_engine->fd_orphan(fd, on_done, release_fd, reason); } void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why) { @@ -231,6 +235,10 @@ void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { g_event_engine->fd_notify_on_write(fd, closure); } +void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { + g_event_engine->fd_notify_on_error(fd, closure); +} + static size_t pollset_size(void) { return g_event_engine->pollset_size; } static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { @@ -334,4 +342,4 @@ void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) { g_event_engine->pollset_set_del_fd(pollset_set, fd); } -#endif // GRPC_POSIX_SOCKET +#endif // GRPC_POSIX_SOCKET_EV diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 82cbce9a7b..b4c17fc80d 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -41,14 +41,16 @@ typedef struct grpc_fd grpc_fd; typedef struct grpc_event_engine_vtable { size_t pollset_size; + bool can_track_err; - grpc_fd* (*fd_create)(int fd, const char* name); + grpc_fd* (*fd_create)(int fd, const char* name, bool track_err); int (*fd_wrapped_fd)(grpc_fd* fd); void (*fd_orphan)(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason); + const char* reason); void (*fd_shutdown)(grpc_fd* fd, grpc_error* why); void (*fd_notify_on_read)(grpc_fd* fd, grpc_closure* closure); void (*fd_notify_on_write)(grpc_fd* fd, grpc_closure* closure); + void (*fd_notify_on_error)(grpc_fd* fd, grpc_closure* closure); bool (*fd_is_shutdown)(grpc_fd* fd); grpc_pollset* (*fd_get_read_notifier_pollset)(grpc_fd* fd); @@ -84,10 +86,20 @@ void grpc_event_engine_shutdown(void); /* Return the name of the poll strategy */ const char* grpc_get_poll_strategy_name(); +/* Returns true if polling engine can track errors separately, false otherwise. + * If this is true, fd can be created with track_err set. After this, error + * events will be reported using fd_notify_on_error. If it is not set, errors + * will continue to be reported through fd_notify_on_read and + * fd_notify_on_write. + */ +bool grpc_event_engine_can_track_errors(); + /* Create a wrapped file descriptor. Requires fd is a non-blocking file descriptor. + \a track_err if true means that error events would be tracked separately + using grpc_fd_notify_on_error. Currently, valid only for linux systems. This takes ownership of closing fd. */ -grpc_fd* grpc_fd_create(int fd, const char* name); +grpc_fd* grpc_fd_create(int fd, const char* name, bool track_err); /* Return the wrapped fd, or -1 if it has been released or closed. */ int grpc_fd_wrapped_fd(grpc_fd* fd); @@ -100,7 +112,7 @@ int grpc_fd_wrapped_fd(grpc_fd* fd); notify_on_write. MUST NOT be called with a pollset lock taken */ void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, - bool already_closed, const char* reason); + const char* reason); /* Has grpc_fd_shutdown been called on an fd? */ bool grpc_fd_is_shutdown(grpc_fd* fd); @@ -126,6 +138,10 @@ void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure); /* Exactly the same semantics as above, except based on writable events. */ void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure); +/* Exactly the same semantics as above, except based on error events. track_err + * needs to have been set on grpc_fd_create */ +void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure); + /* Return the read notifier pollset from the fd */ grpc_pollset* grpc_fd_get_read_notifier_pollset(grpc_fd* fd); diff --git a/src/core/lib/iomgr/iomgr_posix.cc b/src/core/lib/iomgr/iomgr_posix.cc index 66c9cb7ff7..ca7334c9a4 100644 --- a/src/core/lib/iomgr/iomgr_posix.cc +++ b/src/core/lib/iomgr/iomgr_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_IOMGR #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/ev_posix.h" @@ -64,4 +64,4 @@ void grpc_set_default_iomgr_platform() { grpc_set_iomgr_platform_vtable(&vtable); } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_IOMGR */ diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc index 9f164f65b0..dea07cae53 100644 --- a/src/core/lib/iomgr/polling_entity.cc +++ b/src/core/lib/iomgr/polling_entity.cc @@ -61,8 +61,11 @@ bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent) { void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent, grpc_pollset_set* pss_dst) { if (pollent->tag == GRPC_POLLS_POLLSET) { - GPR_ASSERT(pollent->pollent.pollset != nullptr); - grpc_pollset_set_add_pollset(pss_dst, pollent->pollent.pollset); + // CFStream does not use file destriptors. When CFStream is used, the fd + // pollset is possible to be null. + if (pollent->pollent.pollset != nullptr) { + grpc_pollset_set_add_pollset(pss_dst, pollent->pollent.pollset); + } } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) { GPR_ASSERT(pollent->pollent.pollset_set != nullptr); grpc_pollset_set_add_pollset_set(pss_dst, pollent->pollent.pollset_set); @@ -75,8 +78,14 @@ void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent, void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent, grpc_pollset_set* pss_dst) { if (pollent->tag == GRPC_POLLS_POLLSET) { +#ifdef GRPC_CFSTREAM + if (pollent->pollent.pollset != nullptr) { + grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset); + } +#else GPR_ASSERT(pollent->pollent.pollset != nullptr); grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset); +#endif } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) { GPR_ASSERT(pollent->pollent.pollset_set != nullptr); grpc_pollset_set_del_pollset_set(pss_dst, pollent->pollent.pollset_set); diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index a397012003..80d8e63cdd 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -97,7 +97,26 @@ #define GRPC_MSG_IOVLEN_TYPE int #define GRPC_POSIX_FORK 1 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#ifdef GRPC_CFSTREAM +#define GRPC_POSIX_SOCKET_IOMGR 1 +#define GRPC_CFSTREAM_ENDPOINT 1 +#define GRPC_CFSTREAM_CLIENT 1 +#define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 +#define GRPC_POSIX_SOCKET_EV 1 +#define GRPC_POSIX_SOCKET_EV_EPOLL1 1 +#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1 +#define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1 +#define GRPC_POSIX_SOCKET_EV_POLL 1 +#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 +#define GRPC_POSIX_SOCKET_SOCKADDR 1 +#define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 +#define GRPC_POSIX_SOCKET_TCP 1 +#define GRPC_POSIX_SOCKET_TCP_SERVER 1 +#define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 +#define GRPC_POSIX_SOCKET_UTILS_COMMON 1 +#else #define GRPC_POSIX_SOCKET 1 +#endif #define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_POSIX_SYSCONF 1 #define GRPC_POSIX_WAKEUP_FD 1 @@ -131,12 +150,30 @@ #endif #if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ - defined(GRPC_CUSTOM_SOCKET) != \ + defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_CFSTREAM) != \ 1 #error \ "Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GRPC_CUSTOM_SOCKET" #endif +#ifdef GRPC_POSIX_SOCKET +#define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 +#define GRPC_POSIX_SOCKET_EV 1 +#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1 +#define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1 +#define GRPC_POSIX_SOCKET_EV_POLL 1 +#define GRPC_POSIX_SOCKET_EV_EPOLL1 1 +#define GRPC_POSIX_SOCKET_IOMGR 1 +#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 +#define GRPC_POSIX_SOCKET_SOCKADDR 1 +#define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 +#define GRPC_POSIX_SOCKET_TCP 1 +#define GRPC_POSIX_SOCKET_TCP_CLIENT 1 +#define GRPC_POSIX_SOCKET_TCP_SERVER 1 +#define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 +#define GRPC_POSIX_SOCKET_UTILS_COMMON 1 +#endif + #if defined(GRPC_POSIX_HOST_NAME_MAX) && defined(GRPC_POSIX_SYSCONF) #error "Cannot define both GRPC_POSIX_HOST_NAME_MAX and GRPC_POSIX_SYSCONF" #endif diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index fe0d834582..6afe94a7a9 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -33,7 +33,7 @@ #include <ws2tcpip.h> #endif -#ifdef GRPC_POSIX_SOCKET +#if defined(GRPC_POSIX_SOCKET) || defined(GRPC_CFSTREAM) #include <sys/socket.h> #endif diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index a82075542f..7a825643e1 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -19,7 +19,7 @@ #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_RESOLVE_ADDRESS #include "src/core/lib/iomgr/sockaddr.h" diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 539bc120ce..8a308f71bb 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -30,6 +30,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/combiner.h" @@ -670,18 +671,9 @@ size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) { grpc_resource_quota* grpc_resource_quota_from_channel_args( const grpc_channel_args* channel_args) { - for (size_t i = 0; i < channel_args->num_args; i++) { - if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) { - if (channel_args->args[i].type == GRPC_ARG_POINTER) { - return grpc_resource_quota_ref_internal( - static_cast<grpc_resource_quota*>( - channel_args->args[i].value.pointer.p)); - } else { - gpr_log(GPR_DEBUG, GRPC_ARG_RESOURCE_QUOTA " should be a pointer"); - } - } - } - return grpc_resource_quota_create(nullptr); + grpc_resource_quota* rq = grpc_channel_args_get_pointer<grpc_resource_quota>( + channel_args, GRPC_ARG_RESOURCE_QUOTA); + return rq == nullptr ? grpc_resource_quota_create(nullptr) : rq; } static void* rq_copy(void* rq) { diff --git a/src/core/lib/iomgr/sockaddr_posix.h b/src/core/lib/iomgr/sockaddr_posix.h index 5b18bbc465..3cedd9082d 100644 --- a/src/core/lib/iomgr/sockaddr_posix.h +++ b/src/core/lib/iomgr/sockaddr_posix.h @@ -23,7 +23,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_SOCKADDR #include <arpa/inet.h> #include <netdb.h> #include <netinet/in.h> diff --git a/src/core/lib/iomgr/socket_factory_posix.cc b/src/core/lib/iomgr/socket_factory_posix.cc index 1d1e36c0e3..57137769c8 100644 --- a/src/core/lib/iomgr/socket_factory_posix.cc +++ b/src/core/lib/iomgr/socket_factory_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_SOCKET_FACTORY #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/useful.h" diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 04a1767731..caee652307 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc new file mode 100644 index 0000000000..5acea91792 --- /dev/null +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -0,0 +1,216 @@ + +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <grpc/support/port_platform.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM_CLIENT + +#include <CoreFoundation/CoreFoundation.h> + +#include <string.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/sync.h> + +#include <netinet/in.h> + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/iomgr/cfstream_handle.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/endpoint_cfstream.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/error_cfstream.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/tcp_client.h" +#include "src/core/lib/iomgr/timer.h" + +extern grpc_core::TraceFlag grpc_tcp_trace; + +typedef struct CFStreamConnect { + gpr_mu mu; + gpr_refcount refcount; + + CFReadStreamRef read_stream; + CFWriteStreamRef write_stream; + CFStreamHandle* stream_handle; + + grpc_timer alarm; + grpc_closure on_alarm; + grpc_closure on_open; + + bool read_stream_open; + bool write_stream_open; + bool failed; + + grpc_closure* closure; + grpc_endpoint** endpoint; + int refs; + char* addr_name; + grpc_resource_quota* resource_quota; +} CFStreamConnect; + +static void CFStreamConnectCleanup(CFStreamConnect* connect) { + grpc_resource_quota_unref_internal(connect->resource_quota); + CFSTREAM_HANDLE_UNREF(connect->stream_handle, "async connect clean up"); + CFRelease(connect->read_stream); + CFRelease(connect->write_stream); + gpr_mu_destroy(&connect->mu); + gpr_free(connect->addr_name); + gpr_free(connect); +} + +static void OnAlarm(void* arg, grpc_error* error) { + CFStreamConnect* connect = static_cast<CFStreamConnect*>(arg); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnAlarm, error:%p", connect, error); + } + gpr_mu_lock(&connect->mu); + grpc_closure* closure = connect->closure; + connect->closure = nil; + const bool done = (--connect->refs == 0); + gpr_mu_unlock(&connect->mu); + // Only schedule a callback once, by either OnAlarm or OnOpen. The + // first one issues callback while the second one does cleanup. + if (done) { + CFStreamConnectCleanup(connect); + } else { + grpc_error* error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out"); + GRPC_CLOSURE_SCHED(closure, error); + } +} + +static void OnOpen(void* arg, grpc_error* error) { + CFStreamConnect* connect = static_cast<CFStreamConnect*>(arg); + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnOpen, error:%p", connect, error); + } + gpr_mu_lock(&connect->mu); + grpc_timer_cancel(&connect->alarm); + grpc_closure* closure = connect->closure; + connect->closure = nil; + + bool done = (--connect->refs == 0); + grpc_endpoint** endpoint = connect->endpoint; + + // Only schedule a callback once, by either OnAlarm or OnOpen. The + // first one issues callback while the second one does cleanup. + if (done) { + gpr_mu_unlock(&connect->mu); + CFStreamConnectCleanup(connect); + } else { + if (error == GRPC_ERROR_NONE) { + CFErrorRef stream_error = CFReadStreamCopyError(connect->read_stream); + if (stream_error == NULL) { + stream_error = CFWriteStreamCopyError(connect->write_stream); + } + if (stream_error) { + error = GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "connect() error"); + CFRelease(stream_error); + } + if (error == GRPC_ERROR_NONE) { + *endpoint = grpc_cfstream_endpoint_create( + connect->read_stream, connect->write_stream, connect->addr_name, + connect->resource_quota, connect->stream_handle); + } + } else { + GRPC_ERROR_REF(error); + } + gpr_mu_unlock(&connect->mu); + GRPC_CLOSURE_SCHED(closure, error); + } +} + +static void ParseResolvedAddress(const grpc_resolved_address* addr, + CFStringRef* host, int* port) { + char *host_port, *host_string, *port_string; + grpc_sockaddr_to_string(&host_port, addr, 1); + gpr_split_host_port(host_port, &host_string, &port_string); + *host = CFStringCreateWithCString(NULL, host_string, kCFStringEncodingUTF8); + gpr_free(host_string); + gpr_free(port_string); + gpr_free(host_port); + *port = grpc_sockaddr_get_port(addr); +} + +static void CFStreamClientConnect(grpc_closure* closure, grpc_endpoint** ep, + grpc_pollset_set* interested_parties, + const grpc_channel_args* channel_args, + const grpc_resolved_address* resolved_addr, + grpc_millis deadline) { + CFStreamConnect* connect; + + connect = (CFStreamConnect*)gpr_zalloc(sizeof(CFStreamConnect)); + connect->closure = closure; + connect->endpoint = ep; + connect->addr_name = grpc_sockaddr_to_uri(resolved_addr); + // connect->resource_quota = resource_quota; + connect->refs = 2; // One for the connect operation, one for the timer. + gpr_ref_init(&connect->refcount, 1); + gpr_mu_init(&connect->mu); + + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %p, %s: asynchronously connecting", + connect, connect->addr_name); + } + + grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL); + if (channel_args != NULL) { + for (size_t i = 0; i < channel_args->num_args; i++) { + if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) { + grpc_resource_quota_unref_internal(resource_quota); + resource_quota = grpc_resource_quota_ref_internal( + (grpc_resource_quota*)channel_args->args[i].value.pointer.p); + } + } + } + connect->resource_quota = resource_quota; + + CFReadStreamRef read_stream; + CFWriteStreamRef write_stream; + + CFStringRef host; + int port; + ParseResolvedAddress(resolved_addr, &host, &port); + CFStreamCreatePairWithSocketToHost(NULL, host, port, &read_stream, + &write_stream); + CFRelease(host); + connect->read_stream = read_stream; + connect->write_stream = write_stream; + connect->stream_handle = + CFStreamHandle::CreateStreamHandle(read_stream, write_stream); + GRPC_CLOSURE_INIT(&connect->on_open, OnOpen, static_cast<void*>(connect), + grpc_schedule_on_exec_ctx); + connect->stream_handle->NotifyOnOpen(&connect->on_open); + GRPC_CLOSURE_INIT(&connect->on_alarm, OnAlarm, connect, + grpc_schedule_on_exec_ctx); + gpr_mu_lock(&connect->mu); + CFReadStreamOpen(read_stream); + CFWriteStreamOpen(write_stream); + grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm); + gpr_mu_unlock(&connect->mu); +} + +grpc_tcp_client_vtable grpc_posix_tcp_client_vtable = {CFStreamClientConnect}; + +#endif /* GRPC_CFSTREAM_CLIENT */ diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index 900c056575..30015fc203 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP_CLIENT #include "src/core/lib/iomgr/tcp_client_posix.h" @@ -66,6 +66,7 @@ typedef struct { static grpc_error* prepare_socket(const grpc_resolved_address* addr, int fd, const grpc_channel_args* channel_args) { grpc_error* err = GRPC_ERROR_NONE; + grpc_socket_mutator* mutator = nullptr; GPR_ASSERT(fd >= 0); @@ -79,16 +80,11 @@ static grpc_error* prepare_socket(const grpc_resolved_address* addr, int fd, } err = grpc_set_socket_no_sigpipe_if_possible(fd); if (err != GRPC_ERROR_NONE) goto error; - if (channel_args) { - for (size_t i = 0; i < channel_args->num_args; i++) { - if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) { - GPR_ASSERT(channel_args->args[i].type == GRPC_ARG_POINTER); - grpc_socket_mutator* mutator = static_cast<grpc_socket_mutator*>( - channel_args->args[i].value.pointer.p); - err = grpc_set_socket_with_mutator(fd, mutator); - if (err != GRPC_ERROR_NONE) goto error; - } - } + mutator = grpc_channel_args_get_pointer<grpc_socket_mutator>( + channel_args, GRPC_ARG_SOCKET_MUTATOR); + if (mutator != nullptr) { + err = grpc_set_socket_with_mutator(fd, mutator); + if (err != GRPC_ERROR_NONE) goto error; } goto done; @@ -211,8 +207,7 @@ static void on_writable(void* acp, grpc_error* error) { finish: if (fd != nullptr) { grpc_pollset_set_del_fd(ac->interested_parties, fd); - grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, - "tcp_client_orphan"); + grpc_fd_orphan(fd, nullptr, nullptr, "tcp_client_orphan"); fd = nullptr; } done = (--ac->refs == 0); @@ -280,7 +275,7 @@ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args, } addr_str = grpc_sockaddr_to_uri(mapped_addr); gpr_asprintf(&name, "tcp-client:%s", addr_str); - *fdobj = grpc_fd_create(fd, name); + *fdobj = grpc_fd_create(fd, name, false); gpr_free(name); gpr_free(addr_str); return GRPC_ERROR_NONE; @@ -305,8 +300,7 @@ void grpc_tcp_client_create_from_prepared_fd( return; } if (errno != EWOULDBLOCK && errno != EINPROGRESS) { - grpc_fd_orphan(fdobj, nullptr, nullptr, false /* already_closed */, - "tcp_client_connect_error"); + grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error"); GRPC_CLOSURE_SCHED(closure, GRPC_OS_ERROR(errno, "connect")); return; } diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 96b779bc29..9df2e206b2 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include "src/core/lib/iomgr/network_status_tracker.h" #include "src/core/lib/iomgr/tcp_posix.h" @@ -297,7 +297,7 @@ static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) { static void tcp_free(grpc_tcp* tcp) { grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd, - false /* already_closed */, "tcp_unref_orphan"); + "tcp_unref_orphan"); grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer); grpc_resource_user_unref(tcp->resource_user); gpr_free(tcp->peer_string); @@ -819,4 +819,4 @@ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd, TCP_UNREF(tcp, "destroy"); } -#endif +#endif /* GRPC_POSIX_SOCKET_TCP */ diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 019b354473..a3496de336 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -26,6 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr_custom.h" @@ -80,21 +81,9 @@ static grpc_error* tcp_server_create(grpc_closure* shutdown_complete, const grpc_channel_args* args, grpc_tcp_server** server) { grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server)); - s->resource_quota = grpc_resource_quota_create(nullptr); - for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) { - if (0 == strcmp(GRPC_ARG_RESOURCE_QUOTA, args->args[i].key)) { - if (args->args[i].type == GRPC_ARG_POINTER) { - grpc_resource_quota_unref_internal(s->resource_quota); - s->resource_quota = grpc_resource_quota_ref_internal( - (grpc_resource_quota*)args->args[i].value.pointer.p); - } else { - grpc_resource_quota_unref_internal(s->resource_quota); - gpr_free(s); - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - GRPC_ARG_RESOURCE_QUOTA " must be a pointer to a buffer pool"); - } - } - } + grpc_resource_quota* rq = grpc_channel_args_get_pointer<grpc_resource_quota>( + args, GRPC_ARG_RESOURCE_QUOTA); + s->resource_quota = rq == nullptr ? grpc_resource_quota_create(nullptr) : rq; gpr_ref_init(&s->refs, 1); s->on_accept_cb = nullptr; s->on_accept_cb_arg = nullptr; diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 484d2b6077..0a9b4bfd5f 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -25,7 +25,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP_SERVER #include "src/core/lib/iomgr/tcp_server.h" @@ -64,22 +64,11 @@ static grpc_error* tcp_server_create(grpc_closure* shutdown_complete, s->expand_wildcard_addrs = false; for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) { if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) { - if (args->args[i].type == GRPC_ARG_INTEGER) { - s->so_reuseport = grpc_is_socket_reuse_port_supported() && - (args->args[i].value.integer != 0); - } else { - gpr_free(s); - return GRPC_ERROR_CREATE_FROM_STATIC_STRING(GRPC_ARG_ALLOW_REUSEPORT - " must be an integer"); - } + s->so_reuseport = grpc_channel_arg_get_bool( + &args->args[i], grpc_is_socket_reuse_port_supported()); } else if (0 == strcmp(GRPC_ARG_EXPAND_WILDCARD_ADDRS, args->args[i].key)) { - if (args->args[i].type == GRPC_ARG_INTEGER) { - s->expand_wildcard_addrs = (args->args[i].value.integer != 0); - } else { - gpr_free(s); - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - GRPC_ARG_EXPAND_WILDCARD_ADDRS " must be an integer"); - } + s->expand_wildcard_addrs = + grpc_channel_arg_get_bool(&args->args[i], false); } } gpr_ref_init(&s->refs, 1); @@ -150,7 +139,7 @@ static void deactivated_all_ports(grpc_tcp_server* s) { GRPC_CLOSURE_INIT(&sp->destroyed_closure, destroyed_port, s, grpc_schedule_on_exec_ctx); grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr, - false /* already_closed */, "tcp_listener_shutdown"); + "tcp_listener_shutdown"); } gpr_mu_unlock(&s->mu); } else { @@ -226,7 +215,7 @@ static void on_read(void* arg, grpc_error* err) { gpr_log(GPR_INFO, "SERVER_CONNECT: incoming connection: %s", addr_str); } - grpc_fd* fdobj = grpc_fd_create(fd, name); + grpc_fd* fdobj = grpc_fd_create(fd, name, false); read_notifier_pollset = sp->server->pollsets[static_cast<size_t>(gpr_atm_no_barrier_fetch_add( @@ -362,7 +351,7 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) { listener->sibling = sp; sp->server = listener->server; sp->fd = fd; - sp->emfd = grpc_fd_create(fd, name); + sp->emfd = grpc_fd_create(fd, name, false); memcpy(&sp->addr, &listener->addr, sizeof(grpc_resolved_address)); sp->port = port; sp->port_index = listener->port_index; @@ -559,4 +548,4 @@ grpc_tcp_server_vtable grpc_posix_tcp_server_vtable = { tcp_server_shutdown_starting_add, tcp_server_unref, tcp_server_shutdown_listeners}; -#endif +#endif /* GRPC_POSIX_SOCKET_TCP_SERVER */ diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc index 2d95aa66d6..8c254d587b 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +++ b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON #include "src/core/lib/iomgr/tcp_server_utils_posix.h" @@ -34,6 +34,7 @@ #include <grpc/support/string_util.h> #include <grpc/support/sync.h> +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -105,7 +106,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd, s->tail = sp; sp->server = s; sp->fd = fd; - sp->emfd = grpc_fd_create(fd, name); + sp->emfd = grpc_fd_create(fd, name, false); memcpy(&sp->addr, addr, sizeof(grpc_resolved_address)); sp->port = port; sp->port_index = port_index; @@ -149,6 +150,7 @@ grpc_error* grpc_tcp_server_prepare_socket(grpc_tcp_server* s, int fd, bool so_reuseport, int* port) { grpc_resolved_address sockname_temp; grpc_error* err = GRPC_ERROR_NONE; + grpc_socket_mutator* mutator = nullptr; GPR_ASSERT(fd >= 0); @@ -169,17 +171,11 @@ grpc_error* grpc_tcp_server_prepare_socket(grpc_tcp_server* s, int fd, } err = grpc_set_socket_no_sigpipe_if_possible(fd); if (err != GRPC_ERROR_NONE) goto error; - - if (s->channel_args) { - for (size_t i = 0; i < s->channel_args->num_args; i++) { - if (0 == strcmp(s->channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) { - GPR_ASSERT(s->channel_args->args[i].type == GRPC_ARG_POINTER); - grpc_socket_mutator* mutator = static_cast<grpc_socket_mutator*>( - s->channel_args->args[i].value.pointer.p); - err = grpc_set_socket_with_mutator(fd, mutator); - if (err != GRPC_ERROR_NONE) goto error; - } - } + mutator = grpc_channel_args_get_pointer<grpc_socket_mutator>( + s->channel_args, GRPC_ARG_SOCKET_MUTATOR); + if (mutator != nullptr) { + err = grpc_set_socket_with_mutator(fd, mutator); + if (err != GRPC_ERROR_NONE) goto error; } if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)), @@ -217,4 +213,4 @@ error: return ret; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON */ diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc index 51d17eb174..99af977da3 100644 --- a/src/core/lib/iomgr/udp_server.cc +++ b/src/core/lib/iomgr/udp_server.cc @@ -152,7 +152,7 @@ GrpcUdpListener::GrpcUdpListener(grpc_udp_server* server, int fd, grpc_sockaddr_to_string(&addr_str, addr, 1); gpr_asprintf(&name, "udp-server-listener:%s", addr_str); gpr_free(addr_str); - emfd_ = grpc_fd_create(fd, name); + emfd_ = grpc_fd_create(fd, name, false); memcpy(&addr_, addr, sizeof(grpc_resolved_address)); GPR_ASSERT(emfd_); gpr_free(name); @@ -197,14 +197,8 @@ struct grpc_udp_server { }; static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) { - if (args) { - const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY); - if (arg) { - GPR_ASSERT(arg->type == GRPC_ARG_POINTER); - return static_cast<grpc_socket_factory*>(arg->value.pointer.p); - } - } - return nullptr; + return grpc_channel_args_get_pointer<grpc_socket_factory>( + args, GRPC_ARG_SOCKET_FACTORY); } grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) { @@ -300,8 +294,7 @@ void GrpcUdpListener::OrphanFd() { grpc_schedule_on_exec_ctx); /* Because at this point, all listening sockets have been shutdown already, no * need to call OnFdAboutToOrphan() to notify the handler again. */ - grpc_fd_orphan(emfd_, &destroyed_closure_, nullptr, - false /* already_closed */, "udp_listener_shutdown"); + grpc_fd_orphan(emfd_, &destroyed_closure_, nullptr, "udp_listener_shutdown"); } void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) { diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index 14051a3f00..1f93416b23 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -326,23 +326,8 @@ grpc_arg grpc_auth_context_to_arg(grpc_auth_context* p) { &auth_context_pointer_vtable); } -grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) { - if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return nullptr; - if (arg->type != GRPC_ARG_POINTER) { - gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, - GRPC_AUTH_CONTEXT_ARG); - return nullptr; - } - return static_cast<grpc_auth_context*>(arg->value.pointer.p); -} - grpc_auth_context* grpc_find_auth_context_in_args( - const grpc_channel_args* args) { - size_t i; - if (args == nullptr) return nullptr; - for (i = 0; i < args->num_args; i++) { - grpc_auth_context* p = grpc_auth_context_from_arg(&args->args[i]); - if (p != nullptr) return p; - } - return nullptr; + const grpc_channel_args* channel_args) { + return grpc_channel_args_get_pointer<grpc_auth_context>( + channel_args, GRPC_AUTH_CONTEXT_ARG); } diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index e782e4f28f..2f73a5482c 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -108,7 +108,6 @@ void grpc_server_security_context_destroy(void* ctx); #define GRPC_AUTH_CONTEXT_ARG "grpc.auth_context" grpc_arg grpc_auth_context_to_arg(grpc_auth_context* c); -grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg); grpc_auth_context* grpc_find_auth_context_in_args( const grpc_channel_args* args); diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index c43cb440eb..edeea29327 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -168,27 +168,10 @@ grpc_arg grpc_channel_credentials_to_arg( &credentials_pointer_vtable); } -grpc_channel_credentials* grpc_channel_credentials_from_arg( - const grpc_arg* arg) { - if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return nullptr; - if (arg->type != GRPC_ARG_POINTER) { - gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, - GRPC_ARG_CHANNEL_CREDENTIALS); - return nullptr; - } - return static_cast<grpc_channel_credentials*>(arg->value.pointer.p); -} - grpc_channel_credentials* grpc_channel_credentials_find_in_args( - const grpc_channel_args* args) { - size_t i; - if (args == nullptr) return nullptr; - for (i = 0; i < args->num_args; i++) { - grpc_channel_credentials* credentials = - grpc_channel_credentials_from_arg(&args->args[i]); - if (credentials != nullptr) return credentials; - } - return nullptr; + const grpc_channel_args* channel_args) { + return grpc_channel_args_get_pointer<grpc_channel_credentials>( + channel_args, GRPC_ARG_CHANNEL_CREDENTIALS); } grpc_server_credentials* grpc_server_credentials_ref( @@ -263,24 +246,8 @@ grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* p) { &cred_ptr_vtable); } -grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg) { - if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return nullptr; - if (arg->type != GRPC_ARG_POINTER) { - gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, - GRPC_SERVER_CREDENTIALS_ARG); - return nullptr; - } - return static_cast<grpc_server_credentials*>(arg->value.pointer.p); -} - grpc_server_credentials* grpc_find_server_credentials_in_args( - const grpc_channel_args* args) { - size_t i; - if (args == nullptr) return nullptr; - for (i = 0; i < args->num_args; i++) { - grpc_server_credentials* p = - grpc_server_credentials_from_arg(&args->args[i]); - if (p != nullptr) return p; - } - return nullptr; + const grpc_channel_args* channel_args) { + return grpc_channel_args_get_pointer<grpc_server_credentials>( + channel_args, GRPC_SERVER_CREDENTIALS_ARG); } diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index b486d25ab2..ba380283cc 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -131,10 +131,6 @@ grpc_channel_credentials_duplicate_without_call_credentials( /* Util to encapsulate the channel credentials in a channel arg. */ grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials* credentials); -/* Util to get the channel credentials from a channel arg. */ -grpc_channel_credentials* grpc_channel_credentials_from_arg( - const grpc_arg* arg); - /* Util to find the channel credentials from channel args. */ grpc_channel_credentials* grpc_channel_credentials_find_in_args( const grpc_channel_args* args); @@ -227,7 +223,6 @@ void grpc_server_credentials_unref(grpc_server_credentials* creds); #define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials" grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* c); -grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg); grpc_server_credentials* grpc_find_server_credentials_in_args( const grpc_channel_args* args); diff --git a/src/core/lib/security/credentials/fake/fake_credentials.cc b/src/core/lib/security/credentials/fake/fake_credentials.cc index 858ab6b41b..08321a85c6 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.cc +++ b/src/core/lib/security/credentials/fake/fake_credentials.cc @@ -84,9 +84,8 @@ grpc_arg grpc_fake_transport_expected_targets_arg(char* expected_targets) { const char* grpc_fake_transport_get_expected_targets( const grpc_channel_args* args) { - const grpc_arg* expected_target_arg = - grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS); - return grpc_channel_arg_get_string(expected_target_arg); + return grpc_channel_args_get_string(args, + GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS); } /* -- Metadata-only test credentials. -- */ diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 38c9175717..fa565d4ef8 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -79,13 +79,10 @@ static grpc_security_status google_default_create_security_connector( grpc_channel_security_connector** sc, grpc_channel_args** new_args) { grpc_google_default_channel_credentials* c = reinterpret_cast<grpc_google_default_channel_credentials*>(creds); - bool is_grpclb_load_balancer = grpc_channel_arg_get_bool( - grpc_channel_args_find(args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER), - false); - bool is_backend_from_grpclb_load_balancer = grpc_channel_arg_get_bool( - grpc_channel_args_find( - args, GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER), - false); + bool is_grpclb_load_balancer = grpc_channel_args_get_bool( + args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER, false); + bool is_backend_from_grpclb_load_balancer = grpc_channel_args_get_bool( + args, GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER, false); bool use_alts = is_grpclb_load_balancer || is_backend_from_grpclb_load_balancer; grpc_security_status status = GRPC_SECURITY_ERROR; diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 2b6377d3ec..13dae19b4b 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -60,14 +60,12 @@ static grpc_security_status ssl_create_security_connector( tsi_ssl_session_cache* ssl_session_cache = nullptr; for (size_t i = 0; args && i < args->num_args; i++) { grpc_arg* arg = &args->args[i]; - if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 && - arg->type == GRPC_ARG_STRING) { - overridden_target_name = arg->value.string; + if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0) { + overridden_target_name = grpc_channel_arg_get_string(arg); } - if (strcmp(arg->key, GRPC_SSL_SESSION_CACHE_ARG) == 0 && - arg->type == GRPC_ARG_POINTER) { + if (strcmp(arg->key, GRPC_SSL_SESSION_CACHE_ARG) == 0) { ssl_session_cache = - static_cast<tsi_ssl_session_cache*>(arg->value.pointer.p); + grpc_channel_arg_get_pointer<tsi_ssl_session_cache>(arg); } } status = grpc_ssl_channel_security_connector_create( diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index b54a7643e4..ea001d453d 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -255,26 +255,10 @@ grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc) { &connector_arg_vtable); } -grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) { - if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return nullptr; - if (arg->type != GRPC_ARG_POINTER) { - gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, - GRPC_ARG_SECURITY_CONNECTOR); - return nullptr; - } - return static_cast<grpc_security_connector*>(arg->value.pointer.p); -} - grpc_security_connector* grpc_security_connector_find_in_args( - const grpc_channel_args* args) { - size_t i; - if (args == nullptr) return nullptr; - for (i = 0; i < args->num_args; i++) { - grpc_security_connector* sc = - grpc_security_connector_from_arg(&args->args[i]); - if (sc != nullptr) return sc; - } - return nullptr; + const grpc_channel_args* channel_args) { + return grpc_channel_args_get_pointer<grpc_security_connector>( + channel_args, GRPC_ARG_SECURITY_CONNECTOR); } static tsi_client_certificate_request_type diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index f9723166d0..9da66ef01d 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -99,9 +99,6 @@ int grpc_security_connector_cmp(grpc_security_connector* sc, /* Util to encapsulate the connector in a channel arg. */ grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc); -/* Util to get the connector from a channel arg. */ -grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg); - /* Util to find the connector from channel args. */ grpc_security_connector* grpc_security_connector_find_in_args( const grpc_channel_args* args); diff --git a/src/core/lib/security/transport/target_authority_table.cc b/src/core/lib/security/transport/target_authority_table.cc index 1eeb557f6a..467e681a50 100644 --- a/src/core/lib/security/transport/target_authority_table.cc +++ b/src/core/lib/security/transport/target_authority_table.cc @@ -59,17 +59,8 @@ grpc_arg CreateTargetAuthorityTableChannelArg(TargetAuthorityTable* table) { TargetAuthorityTable* FindTargetAuthorityTableInArgs( const grpc_channel_args* args) { - const grpc_arg* arg = - grpc_channel_args_find(args, GRPC_ARG_TARGET_AUTHORITY_TABLE); - if (arg != nullptr) { - if (arg->type == GRPC_ARG_POINTER) { - return static_cast<TargetAuthorityTable*>(arg->value.pointer.p); - } else { - gpr_log(GPR_ERROR, "value of " GRPC_ARG_TARGET_AUTHORITY_TABLE - " channel arg was not pointer type; ignoring"); - } - } - return nullptr; + return grpc_channel_args_get_pointer<TargetAuthorityTable>( + args, GRPC_ARG_TARGET_AUTHORITY_TABLE); } } // namespace grpc_core diff --git a/src/core/lib/security/util/json_util.cc b/src/core/lib/security/util/json_util.cc index 75512a19c9..fe9f5fe3d3 100644 --- a/src/core/lib/security/util/json_util.cc +++ b/src/core/lib/security/util/json_util.cc @@ -29,6 +29,10 @@ const char* grpc_json_get_string_property(const grpc_json* json, const char* prop_name) { grpc_json* child; for (child = json->child; child != nullptr; child = child->next) { + if (child->key == nullptr) { + gpr_log(GPR_ERROR, "Invalid (null) JSON key encountered"); + return nullptr; + } if (strcmp(child->key, prop_name) == 0) break; } if (child == nullptr || child->type != GRPC_JSON_STRING) { diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index fd56997388..1f1c08b159 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -333,14 +333,26 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n, size_t slice_len = GRPC_SLICE_LENGTH(slice); if (slice_len > n) { sb->slices[idx] = grpc_slice_split_head(&slice, slice_len - n); - grpc_slice_buffer_add_indexed(garbage, slice); + if (garbage) { + grpc_slice_buffer_add_indexed(garbage, slice); + } else { + grpc_slice_unref_internal(slice); + } return; } else if (slice_len == n) { - grpc_slice_buffer_add_indexed(garbage, slice); + if (garbage) { + grpc_slice_buffer_add_indexed(garbage, slice); + } else { + grpc_slice_unref_internal(slice); + } sb->count = idx; return; } else { - grpc_slice_buffer_add_indexed(garbage, slice); + if (garbage) { + grpc_slice_buffer_add_indexed(garbage, slice); + } else { + grpc_slice_unref_internal(slice); + } n -= slice_len; sb->count = idx; } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 33b9908a57..2434c9b952 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -520,7 +520,6 @@ static void release_call(void* call, grpc_error* error) { grpc_call* c = static_cast<grpc_call*>(call); grpc_channel* channel = c->channel; grpc_call_combiner_destroy(&c->call_combiner); - gpr_free((char*)c->peer_string); grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(c->arena)); GRPC_CHANNEL_INTERNAL_UNREF(channel, "call"); } diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index 6b41e4b37e..039d603394 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -184,7 +184,8 @@ void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream, nullptr) { transport->vtable->set_pollset_set(transport, stream, pollset_set); } else { - abort(); + // No-op for empty pollset. Empty pollset is possible when using + // non-fd-based event engines such as CFStream. } } diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 10e9df0f7c..b2e252d939 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -168,13 +168,11 @@ struct grpc_transport_stream_op_batch_payload { /** Iff send_initial_metadata != NULL, flags associated with send_initial_metadata: a bitfield of GRPC_INITIAL_METADATA_xxx */ uint32_t send_initial_metadata_flags; - // If non-NULL, will be set by the transport to the peer string - // (a char*, which the caller takes ownership of). + // If non-NULL, will be set by the transport to the peer string (a char*). + // The transport retains ownership of the string. // Note: This pointer may be used by the transport after the // send_initial_metadata op is completed. It must remain valid // until the call is destroyed. - // Note: When a transport sets this, it must free the previous - // value, if any. gpr_atm* peer_string; } send_initial_metadata; @@ -202,13 +200,11 @@ struct grpc_transport_stream_op_batch_payload { // immediately available. This may be a signal that we received a // Trailers-Only response. bool* trailing_metadata_available; - // If non-NULL, will be set by the transport to the peer string - // (a char*, which the caller takes ownership of). + // If non-NULL, will be set by the transport to the peer string (a char*). + // The transport retains ownership of the string. // Note: This pointer may be used by the transport after the // recv_initial_metadata op is completed. It must remain valid // until the call is destroyed. - // Note: When a transport sets this, it must free the previous - // value, if any. gpr_atm* peer_string; } recv_initial_metadata; diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 8065a8b185..e66fc9ba03 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -260,14 +260,13 @@ static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8, X509_NAME* subject_name = X509_get_subject_name(cert); int utf8_returned_size = 0; if (subject_name == nullptr) { - gpr_log(GPR_ERROR, "Could not get subject name from certificate."); + gpr_log(GPR_INFO, "Could not get subject name from certificate."); return TSI_NOT_FOUND; } common_name_index = X509_NAME_get_index_by_NID(subject_name, NID_commonName, -1); if (common_name_index == -1) { - gpr_log(GPR_ERROR, - "Could not get common name of subject from certificate."); + gpr_log(GPR_INFO, "Could not get common name of subject from certificate."); return TSI_NOT_FOUND; } common_name_entry = X509_NAME_get_entry(subject_name, common_name_index); diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index e951801965..7f5b439dfb 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -39,8 +39,8 @@ static void do_plugin_list_init(void) { } ServerBuilder::ServerBuilder() - : max_receive_message_size_(-1), - max_send_message_size_(-1), + : max_receive_message_size_(INT_MIN), + max_send_message_size_(INT_MIN), sync_server_settings_(SyncServerSettings()), resource_quota_(nullptr), generic_service_(nullptr) { @@ -186,10 +186,12 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { (*plugin)->UpdateChannelArguments(&args); } - if (max_receive_message_size_ >= 0) { + 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) { args.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, max_send_message_size_); } diff --git a/src/csharp/Grpc.Core.NativeDebug.nuspec b/src/csharp/Grpc.Core.NativeDebug.nuspec new file mode 100644 index 0000000000..d4bb8ad223 --- /dev/null +++ b/src/csharp/Grpc.Core.NativeDebug.nuspec @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<package> + <metadata> + <id>Grpc.Core.NativeDebug</id> + <title>Grpc.Core: Native Debug Symbols</title> + <summary>Debug symbols for the native library contained in Grpc.Core</summary> + <description>Currently contains grpc_csharp_ext.pdb</description> + <version>$version$</version> + <authors>Google Inc.</authors> + <owners>grpc-packages</owners> + <licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl> + <projectUrl>https://github.com/grpc/grpc</projectUrl> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <releaseNotes>Release $version$</releaseNotes> + <copyright>Copyright 2015, Google Inc.</copyright> + <tags>gRPC RPC Protocol HTTP/2</tags> + </metadata> + <files> + <!-- forward slashes in src path enable building on Linux --> + <file src="nativelibs/csharp_ext_windows_x86/grpc_csharp_ext.dll" target="runtimes/win/native/grpc_csharp_ext.x86.dll" /> + <file src="nativelibs/csharp_ext_windows_x86/grpc_csharp_ext.pdb" target="runtimes/win/native/grpc_csharp_ext.x86.pdb" /> + <file src="nativelibs/csharp_ext_windows_x64/grpc_csharp_ext.dll" target="runtimes/win/native/grpc_csharp_ext.x64.dll" /> + <file src="nativelibs/csharp_ext_windows_x64/grpc_csharp_ext.pdb" target="runtimes/win/native/grpc_csharp_ext.x64.pdb" /> + </files> +</package> diff --git a/src/csharp/Grpc.Core.Testing/TestCalls.cs b/src/csharp/Grpc.Core.Testing/TestCalls.cs index ac29a8b974..8c76781bbe 100644 --- a/src/csharp/Grpc.Core.Testing/TestCalls.cs +++ b/src/csharp/Grpc.Core.Testing/TestCalls.cs @@ -65,7 +65,7 @@ namespace Grpc.Core.Testing /// Creates a test double for <c>AsyncDuplexStreamingCall</c>. Only for testing. /// Note: experimental API that can change or be removed without any prior notice. /// </summary> - public static AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TResponse, TRequest>( + public static AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>( IClientStreamWriter<TRequest> requestStream, IAsyncStreamReader<TResponse> responseStream, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction) diff --git a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj index 3ccc9adfaf..d2cc5bbc65 100755 --- a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj +++ b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj @@ -13,11 +13,13 @@ <ItemGroup> <ProjectReference Include="../Grpc.Examples/Grpc.Examples.csproj" /> + <ProjectReference Include="../Grpc.Core.Testing/Grpc.Core.Testing.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnitLite" Version="3.6.0" /> + <PackageReference Include="Moq" Version="4.8.2" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net45' "> diff --git a/src/csharp/Grpc.Examples.Tests/MathClientMockableTest.cs b/src/csharp/Grpc.Examples.Tests/MathClientMockableTest.cs new file mode 100644 index 0000000000..6ed7b0a937 --- /dev/null +++ b/src/csharp/Grpc.Examples.Tests/MathClientMockableTest.cs @@ -0,0 +1,101 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Testing; +using NUnit.Framework; + +namespace Math.Tests +{ + /// <summary> + /// Demonstrates how to mock method stubs for all method types in a generated client. + /// </summary> + public class MathClientMockableTest + { + [Test] + public void ClientBaseBlockingUnaryCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + + var expected = new DivReply(); + mockClient.Setup(m => m.Div(Moq.It.IsAny<DivArgs>(), null, null, CancellationToken.None)).Returns(expected); + Assert.AreSame(expected, mockClient.Object.Div(new DivArgs())); + } + + [Test] + public void ClientBaseBlockingUnaryCallWithCallOptionsCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + + var expected = new DivReply(); + mockClient.Setup(m => m.Div(Moq.It.IsAny<DivArgs>(), Moq.It.IsAny<CallOptions>())).Returns(expected); + Assert.AreSame(expected, mockClient.Object.Div(new DivArgs(), new CallOptions())); + } + + [Test] + public void ClientBaseAsyncUnaryCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + + // Use a factory method provided by Grpc.Core.Testing.TestCalls to create an instance of a call. + var fakeCall = TestCalls.AsyncUnaryCall<DivReply>(Task.FromResult(new DivReply()), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); + mockClient.Setup(m => m.DivAsync(Moq.It.IsAny<DivArgs>(), null, null, CancellationToken.None)).Returns(fakeCall); + Assert.AreSame(fakeCall, mockClient.Object.DivAsync(new DivArgs())); + } + + [Test] + public void ClientBaseClientStreamingCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + var mockRequestStream = new Moq.Mock<IClientStreamWriter<Num>>(); + + // Use a factory method provided by Grpc.Core.Testing.TestCalls to create an instance of a call. + var fakeCall = TestCalls.AsyncClientStreamingCall<Num, Num>(mockRequestStream.Object, Task.FromResult(new Num()), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); + mockClient.Setup(m => m.Sum(null, null, CancellationToken.None)).Returns(fakeCall); + Assert.AreSame(fakeCall, mockClient.Object.Sum()); + } + + [Test] + public void ClientBaseServerStreamingCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + var mockResponseStream = new Moq.Mock<IAsyncStreamReader<Num>>(); + + // Use a factory method provided by Grpc.Core.Testing.TestCalls to create an instance of a call. + var fakeCall = TestCalls.AsyncServerStreamingCall<Num>(mockResponseStream.Object, Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); + mockClient.Setup(m => m.Fib(Moq.It.IsAny<FibArgs>(), null, null, CancellationToken.None)).Returns(fakeCall); + Assert.AreSame(fakeCall, mockClient.Object.Fib(new FibArgs())); + } + + [Test] + public void ClientBaseDuplexStreamingCallCanBeMocked() + { + var mockClient = new Moq.Mock<Math.MathClient>(); + var mockRequestStream = new Moq.Mock<IClientStreamWriter<DivArgs>>(); + var mockResponseStream = new Moq.Mock<IAsyncStreamReader<DivReply>>(); + + // Use a factory method provided by Grpc.Core.Testing.TestCalls to create an instance of a call. + var fakeCall = TestCalls.AsyncDuplexStreamingCall<DivArgs, DivReply>(mockRequestStream.Object, mockResponseStream.Object, Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); + mockClient.Setup(m => m.DivMany(null, null, CancellationToken.None)).Returns(fakeCall); + Assert.AreSame(fakeCall, mockClient.Object.DivMany()); + } + } +} diff --git a/src/csharp/Grpc.Examples.Tests/MathServiceImplTestabilityTest.cs b/src/csharp/Grpc.Examples.Tests/MathServiceImplTestabilityTest.cs new file mode 100644 index 0000000000..7c5fb94408 --- /dev/null +++ b/src/csharp/Grpc.Examples.Tests/MathServiceImplTestabilityTest.cs @@ -0,0 +1,47 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Testing; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Math.Tests +{ + /// <summary> + /// Demonstrates how to unit test implementations of generated server stubs. + /// </summary> + public class MathServiceImplTestabilityTest + { + [Test] + public async Task ServerCallImplIsTestable() + { + var mathImpl = new MathServiceImpl(); + + // Use a factory method provided by Grpc.Core.Testing.TestServerCallContext to create an instance of server call context. + // This allows testing even those server-side implementations that rely on the contents of ServerCallContext. + var fakeServerCallContext = TestServerCallContext.Create("fooMethod", null, DateTime.UtcNow.AddHours(1), new Metadata(), CancellationToken.None, "127.0.0.1", null, null, (metadata) => TaskUtils.CompletedTask, () => new WriteOptions(), (writeOptions) => { }); + var response = await mathImpl.Div(new DivArgs { Dividend = 10, Divisor = 2 }, fakeServerCallContext); + Assert.AreEqual(5, response.Quotient); + Assert.AreEqual(0, response.Remainder); + } + } +} diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index a4739da81d..9578bb4d81 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -27,38 +27,38 @@ namespace Math { { static readonly string __ServiceName = "math.Math"; - static readonly grpc::Marshaller<global::Math.DivArgs> __Marshaller_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivArgs.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Math.DivReply> __Marshaller_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivReply.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Math.FibArgs> __Marshaller_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.FibArgs.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Math.Num> __Marshaller_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.Num.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Math.DivArgs> __Marshaller_math_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivArgs.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Math.DivReply> __Marshaller_math_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivReply.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Math.FibArgs> __Marshaller_math_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.FibArgs.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Math.Num> __Marshaller_math_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.Num.Parser.ParseFrom); static readonly grpc::Method<global::Math.DivArgs, global::Math.DivReply> __Method_Div = new grpc::Method<global::Math.DivArgs, global::Math.DivReply>( grpc::MethodType.Unary, __ServiceName, "Div", - __Marshaller_DivArgs, - __Marshaller_DivReply); + __Marshaller_math_DivArgs, + __Marshaller_math_DivReply); static readonly grpc::Method<global::Math.DivArgs, global::Math.DivReply> __Method_DivMany = new grpc::Method<global::Math.DivArgs, global::Math.DivReply>( grpc::MethodType.DuplexStreaming, __ServiceName, "DivMany", - __Marshaller_DivArgs, - __Marshaller_DivReply); + __Marshaller_math_DivArgs, + __Marshaller_math_DivReply); static readonly grpc::Method<global::Math.FibArgs, global::Math.Num> __Method_Fib = new grpc::Method<global::Math.FibArgs, global::Math.Num>( grpc::MethodType.ServerStreaming, __ServiceName, "Fib", - __Marshaller_FibArgs, - __Marshaller_Num); + __Marshaller_math_FibArgs, + __Marshaller_math_Num); static readonly grpc::Method<global::Math.Num, global::Math.Num> __Method_Sum = new grpc::Method<global::Math.Num, global::Math.Num>( grpc::MethodType.ClientStreaming, __ServiceName, "Sum", - __Marshaller_Num, - __Marshaller_Num); + __Marshaller_math_Num, + __Marshaller_math_Num); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index ebd890e48d..5e79c04d2a 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -30,15 +30,15 @@ namespace Grpc.Health.V1 { { static readonly string __ServiceName = "grpc.health.v1.Health"; - static readonly grpc::Marshaller<global::Grpc.Health.V1.HealthCheckRequest> __Marshaller_HealthCheckRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Health.V1.HealthCheckResponse> __Marshaller_HealthCheckResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Health.V1.HealthCheckRequest> __Marshaller_grpc_health_v1_HealthCheckRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Health.V1.HealthCheckResponse> __Marshaller_grpc_health_v1_HealthCheckResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse> __Method_Check = new grpc::Method<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse>( grpc::MethodType.Unary, __ServiceName, "Check", - __Marshaller_HealthCheckRequest, - __Marshaller_HealthCheckResponse); + __Marshaller_grpc_health_v1_HealthCheckRequest, + __Marshaller_grpc_health_v1_HealthCheckResponse); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs index e2a4b93cef..b5738593f2 100644 --- a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs @@ -29,43 +29,43 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.BenchmarkService"; - static readonly grpc::Marshaller<global::Grpc.Testing.SimpleRequest> __Marshaller_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.SimpleResponse> __Marshaller_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.SimpleRequest> __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.SimpleResponse> __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_UnaryCall = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.Unary, __ServiceName, "UnaryCall", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_StreamingCall = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.DuplexStreaming, __ServiceName, "StreamingCall", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_StreamingFromClient = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.ClientStreaming, __ServiceName, "StreamingFromClient", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_StreamingFromServer = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.ServerStreaming, __ServiceName, "StreamingFromServer", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_StreamingBothWays = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.DuplexStreaming, __ServiceName, "StreamingBothWays", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs b/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs index 2462606879..c8bcb7a93f 100644 --- a/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/GeneratedClientTest.cs @@ -34,29 +34,6 @@ namespace Grpc.IntegrationTesting TestService.TestServiceClient unimplementedClient = new UnimplementedTestServiceClient(); [Test] - public void ExpandedParamOverloadCanBeMocked() - { - var expected = new SimpleResponse(); - - var mockClient = new Moq.Mock<TestService.TestServiceClient>(); - // mocking is relatively clumsy because one needs to specify value for all the optional params. - mockClient.Setup(m => m.UnaryCall(Moq.It.IsAny<SimpleRequest>(), null, null, CancellationToken.None)).Returns(expected); - - Assert.AreSame(expected, mockClient.Object.UnaryCall(new SimpleRequest())); - } - - [Test] - public void CallOptionsOverloadCanBeMocked() - { - var expected = new SimpleResponse(); - - var mockClient = new Moq.Mock<TestService.TestServiceClient>(); - mockClient.Setup(m => m.UnaryCall(Moq.It.IsAny<SimpleRequest>(), Moq.It.IsAny<CallOptions>())).Returns(expected); - - Assert.AreSame(expected, mockClient.Object.UnaryCall(new SimpleRequest(), new CallOptions())); - } - - [Test] public void DefaultMethodStubThrows_UnaryCall() { Assert.Throws(typeof(NotImplementedException), () => unimplementedClient.UnaryCall(new SimpleRequest())); diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index ba2107a576..e4f36d8810 100755 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -19,7 +19,6 @@ <ItemGroup> <PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufVersion)" /> <PackageReference Include="CommandLineParser" Version="2.1.1-beta" /> - <PackageReference Include="Moq" Version="4.8.2" /> <PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnitLite" Version="3.6.0" /> </ItemGroup> diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index e8c566e167..9f16f41ac1 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -33,23 +33,23 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.MetricsService"; - static readonly grpc::Marshaller<global::Grpc.Testing.EmptyMessage> __Marshaller_EmptyMessage = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.GaugeResponse> __Marshaller_GaugeResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.GaugeRequest> __Marshaller_GaugeRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.EmptyMessage> __Marshaller_grpc_testing_EmptyMessage = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.GaugeResponse> __Marshaller_grpc_testing_GaugeResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.GaugeRequest> __Marshaller_grpc_testing_GaugeRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse> __Method_GetAllGauges = new grpc::Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse>( grpc::MethodType.ServerStreaming, __ServiceName, "GetAllGauges", - __Marshaller_EmptyMessage, - __Marshaller_GaugeResponse); + __Marshaller_grpc_testing_EmptyMessage, + __Marshaller_grpc_testing_GaugeResponse); static readonly grpc::Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse> __Method_GetGauge = new grpc::Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse>( grpc::MethodType.Unary, __ServiceName, "GetGauge", - __Marshaller_GaugeRequest, - __Marshaller_GaugeResponse); + __Marshaller_grpc_testing_GaugeRequest, + __Marshaller_grpc_testing_GaugeResponse); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs index 60a3890f21..1da0548cb4 100644 --- a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs @@ -29,15 +29,15 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReportQpsScenarioService"; - static readonly grpc::Marshaller<global::Grpc.Testing.ScenarioResult> __Marshaller_ScenarioResult = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ScenarioResult.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.Void> __Marshaller_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ScenarioResult> __Marshaller_grpc_testing_ScenarioResult = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ScenarioResult.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.Void> __Marshaller_grpc_testing_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.ScenarioResult, global::Grpc.Testing.Void> __Method_ReportScenario = new grpc::Method<global::Grpc.Testing.ScenarioResult, global::Grpc.Testing.Void>( grpc::MethodType.Unary, __ServiceName, "ReportScenario", - __Marshaller_ScenarioResult, - __Marshaller_Void); + __Marshaller_grpc_testing_ScenarioResult, + __Marshaller_grpc_testing_Void); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index aec4ce7be7..2176916b43 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -34,69 +34,69 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.TestService"; - static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.SimpleRequest> __Marshaller_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.SimpleResponse> __Marshaller_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.StreamingOutputCallRequest> __Marshaller_StreamingOutputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.StreamingOutputCallResponse> __Marshaller_StreamingOutputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallResponse.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.StreamingInputCallRequest> __Marshaller_StreamingInputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.StreamingInputCallResponse> __Marshaller_StreamingInputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.SimpleRequest> __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.SimpleResponse> __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.StreamingOutputCallRequest> __Marshaller_grpc_testing_StreamingOutputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.StreamingOutputCallResponse> __Marshaller_grpc_testing_StreamingOutputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.StreamingInputCallRequest> __Marshaller_grpc_testing_StreamingInputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.StreamingInputCallResponse> __Marshaller_grpc_testing_StreamingInputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallResponse.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_EmptyCall = new grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>( grpc::MethodType.Unary, __ServiceName, "EmptyCall", - __Marshaller_Empty, - __Marshaller_Empty); + __Marshaller_grpc_testing_Empty, + __Marshaller_grpc_testing_Empty); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_UnaryCall = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.Unary, __ServiceName, "UnaryCall", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_CacheableUnaryCall = new grpc::Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>( grpc::MethodType.Unary, __ServiceName, "CacheableUnaryCall", - __Marshaller_SimpleRequest, - __Marshaller_SimpleResponse); + __Marshaller_grpc_testing_SimpleRequest, + __Marshaller_grpc_testing_SimpleResponse); static readonly grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse> __Method_StreamingOutputCall = new grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>( grpc::MethodType.ServerStreaming, __ServiceName, "StreamingOutputCall", - __Marshaller_StreamingOutputCallRequest, - __Marshaller_StreamingOutputCallResponse); + __Marshaller_grpc_testing_StreamingOutputCallRequest, + __Marshaller_grpc_testing_StreamingOutputCallResponse); static readonly grpc::Method<global::Grpc.Testing.StreamingInputCallRequest, global::Grpc.Testing.StreamingInputCallResponse> __Method_StreamingInputCall = new grpc::Method<global::Grpc.Testing.StreamingInputCallRequest, global::Grpc.Testing.StreamingInputCallResponse>( grpc::MethodType.ClientStreaming, __ServiceName, "StreamingInputCall", - __Marshaller_StreamingInputCallRequest, - __Marshaller_StreamingInputCallResponse); + __Marshaller_grpc_testing_StreamingInputCallRequest, + __Marshaller_grpc_testing_StreamingInputCallResponse); static readonly grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse> __Method_FullDuplexCall = new grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>( grpc::MethodType.DuplexStreaming, __ServiceName, "FullDuplexCall", - __Marshaller_StreamingOutputCallRequest, - __Marshaller_StreamingOutputCallResponse); + __Marshaller_grpc_testing_StreamingOutputCallRequest, + __Marshaller_grpc_testing_StreamingOutputCallResponse); static readonly grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse> __Method_HalfDuplexCall = new grpc::Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>( grpc::MethodType.DuplexStreaming, __ServiceName, "HalfDuplexCall", - __Marshaller_StreamingOutputCallRequest, - __Marshaller_StreamingOutputCallResponse); + __Marshaller_grpc_testing_StreamingOutputCallRequest, + __Marshaller_grpc_testing_StreamingOutputCallResponse); static readonly grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_UnimplementedCall = new grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>( grpc::MethodType.Unary, __ServiceName, "UnimplementedCall", - __Marshaller_Empty, - __Marshaller_Empty); + __Marshaller_grpc_testing_Empty, + __Marshaller_grpc_testing_Empty); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor @@ -548,14 +548,14 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.UnimplementedService"; - static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_UnimplementedCall = new grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>( grpc::MethodType.Unary, __ServiceName, "UnimplementedCall", - __Marshaller_Empty, - __Marshaller_Empty); + __Marshaller_grpc_testing_Empty, + __Marshaller_grpc_testing_Empty); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor @@ -669,23 +669,23 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReconnectService"; - static readonly grpc::Marshaller<global::Grpc.Testing.ReconnectParams> __Marshaller_ReconnectParams = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.ReconnectInfo> __Marshaller_ReconnectInfo = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ReconnectParams> __Marshaller_grpc_testing_ReconnectParams = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.Empty> __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ReconnectInfo> __Marshaller_grpc_testing_ReconnectInfo = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty> __Method_Start = new grpc::Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty>( grpc::MethodType.Unary, __ServiceName, "Start", - __Marshaller_ReconnectParams, - __Marshaller_Empty); + __Marshaller_grpc_testing_ReconnectParams, + __Marshaller_grpc_testing_Empty); static readonly grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo> __Method_Stop = new grpc::Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo>( grpc::MethodType.Unary, __ServiceName, "Stop", - __Marshaller_Empty, - __Marshaller_ReconnectInfo); + __Marshaller_grpc_testing_Empty, + __Marshaller_grpc_testing_ReconnectInfo); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs index 85f2cfd871..b9e8f91231 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs @@ -29,41 +29,41 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.WorkerService"; - static readonly grpc::Marshaller<global::Grpc.Testing.ServerArgs> __Marshaller_ServerArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerArgs.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.ServerStatus> __Marshaller_ServerStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.ClientArgs> __Marshaller_ClientArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.ClientStatus> __Marshaller_ClientStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.CoreRequest> __Marshaller_CoreRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.CoreResponse> __Marshaller_CoreResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Testing.Void> __Marshaller_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ServerArgs> __Marshaller_grpc_testing_ServerArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerArgs.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ServerStatus> __Marshaller_grpc_testing_ServerStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ClientArgs> __Marshaller_grpc_testing_ClientArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.ClientStatus> __Marshaller_grpc_testing_ClientStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.CoreRequest> __Marshaller_grpc_testing_CoreRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.CoreResponse> __Marshaller_grpc_testing_CoreResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Testing.Void> __Marshaller_grpc_testing_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Testing.ServerArgs, global::Grpc.Testing.ServerStatus> __Method_RunServer = new grpc::Method<global::Grpc.Testing.ServerArgs, global::Grpc.Testing.ServerStatus>( grpc::MethodType.DuplexStreaming, __ServiceName, "RunServer", - __Marshaller_ServerArgs, - __Marshaller_ServerStatus); + __Marshaller_grpc_testing_ServerArgs, + __Marshaller_grpc_testing_ServerStatus); static readonly grpc::Method<global::Grpc.Testing.ClientArgs, global::Grpc.Testing.ClientStatus> __Method_RunClient = new grpc::Method<global::Grpc.Testing.ClientArgs, global::Grpc.Testing.ClientStatus>( grpc::MethodType.DuplexStreaming, __ServiceName, "RunClient", - __Marshaller_ClientArgs, - __Marshaller_ClientStatus); + __Marshaller_grpc_testing_ClientArgs, + __Marshaller_grpc_testing_ClientStatus); static readonly grpc::Method<global::Grpc.Testing.CoreRequest, global::Grpc.Testing.CoreResponse> __Method_CoreCount = new grpc::Method<global::Grpc.Testing.CoreRequest, global::Grpc.Testing.CoreResponse>( grpc::MethodType.Unary, __ServiceName, "CoreCount", - __Marshaller_CoreRequest, - __Marshaller_CoreResponse); + __Marshaller_grpc_testing_CoreRequest, + __Marshaller_grpc_testing_CoreResponse); static readonly grpc::Method<global::Grpc.Testing.Void, global::Grpc.Testing.Void> __Method_QuitWorker = new grpc::Method<global::Grpc.Testing.Void, global::Grpc.Testing.Void>( grpc::MethodType.Unary, __ServiceName, "QuitWorker", - __Marshaller_Void, - __Marshaller_Void); + __Marshaller_grpc_testing_Void, + __Marshaller_grpc_testing_Void); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs index 387c9fb52f..c00075b7c6 100644 --- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -29,15 +29,15 @@ namespace Grpc.Reflection.V1Alpha { { static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; - static readonly grpc::Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest> __Marshaller_ServerReflectionRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); - static readonly grpc::Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> __Marshaller_ServerReflectionResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest> __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); static readonly grpc::Method<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> __Method_ServerReflectionInfo = new grpc::Method<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse>( grpc::MethodType.DuplexStreaming, __ServiceName, "ServerReflectionInfo", - __Marshaller_ServerReflectionRequest, - __Marshaller_ServerReflectionResponse); + __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest, + __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse); /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 924d7b1697..f1111781e2 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -47,6 +47,7 @@ xcopy /Y /I nativelibs\csharp_ext_windows_x64\grpc_csharp_ext.dll ..\..\cmake\bu %DOTNET% pack --configuration Release Grpc.Reflection --output ..\..\..\artifacts || goto :error %NUGET% pack Grpc.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts || goto :error +%NUGET% pack Grpc.Core.NativeDebug.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts %NUGET% pack Grpc.Tools.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts @rem copy resulting nuget packages to artifacts directory diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 5c73a8f95f..fb4138a4b2 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -46,6 +46,7 @@ dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts nuget pack Grpc.nuspec -Version "1.13.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.Core.NativeDebug.nuspec -Version "1.13.0-dev" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "1.13.0-dev" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 60f67ff3c9..c2f243fe0a 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -41,7 +41,9 @@ "Grpc.Core.Tests.UserAgentStringTest" ], "Grpc.Examples.Tests": [ - "Math.Tests.MathClientServerTest" + "Math.Tests.MathClientMockableTest", + "Math.Tests.MathClientServerTest", + "Math.Tests.MathServiceImplTestabilityTest" ], "Grpc.HealthCheck.Tests": [ "Grpc.HealthCheck.Tests.HealthClientServerTest", diff --git a/src/objective-c/GRPCClient/GRPCCall+MobileLog.h b/src/objective-c/GRPCClient/GRPCCall+MobileLog.h deleted file mode 100644 index 53b347d9ca..0000000000 --- a/src/objective-c/GRPCClient/GRPCCall+MobileLog.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCCall.h" - -@interface GRPCCall (MobileLog) -// Set the object to be passed down along channel stack with channel arg -// GRPC_ARG_MOBILE_LOG_CONFIG. The setting may be used by custom channel -// filters for metrics logging. -+ (void)setLogConfig:(id)logConfig; - -// Obtain the object to be passed down along channel stack with channel arg -// GRPC_ARG_MOBILE_LOG_CONFIG. -+ (id)logConfig; -@end diff --git a/src/objective-c/GRPCClient/GRPCCall+MobileLog.m b/src/objective-c/GRPCClient/GRPCCall+MobileLog.m deleted file mode 100644 index 4dedb7de8b..0000000000 --- a/src/objective-c/GRPCClient/GRPCCall+MobileLog.m +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCCall+MobileLog.h" - -static id globalLogConfig = nil; - -@implementation GRPCCall (MobileLog) - -+ (void)setLogConfig:(id)logConfig { - globalLogConfig = logConfig; -} - -+ (id)logConfig { - return globalLogConfig; -} - -@end diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 5b48d06158..9783b06440 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -206,8 +206,9 @@ static NSString *const kBearerPrefix = @"Bearer "; } else { [_responseWriteable enqueueSuccessfulCompletion]; } - +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor unregisterObserver:self]; +#endif // If the call isn't retained anywhere else, it can be deallocated now. _retainSelf = nil; @@ -462,7 +463,9 @@ static NSString *const kBearerPrefix = @"Bearer "; [self sendHeaders:_requestHeaders]; [self invokeCall]; +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)]; +#endif } - (void)startWithWriteable:(id<GRXWriteable>)writeable { diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m index 57dbde8d04..bda1c3360b 100644 --- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m +++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m @@ -20,6 +20,14 @@ #import <grpc/grpc.h> +#ifdef GRPC_CFSTREAM +const grpc_completion_queue_attributes kCompletionQueueAttr = {GRPC_CQ_CURRENT_VERSION, + GRPC_CQ_NEXT, GRPC_CQ_NON_POLLING}; +#else +const grpc_completion_queue_attributes kCompletionQueueAttr = { + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING}; +#endif + @implementation GRPCCompletionQueue + (instancetype)completionQueue { @@ -33,7 +41,8 @@ - (instancetype)init { if ((self = [super init])) { - _unmanagedQueue = grpc_completion_queue_create_for_next(NULL); + _unmanagedQueue = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&kCompletionQueueAttr), &kCompletionQueueAttr, NULL); // This is for the following block to capture the pointer by value (instead // of retaining self and doing self->_unmanagedQueue). This is essential diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h index 6697f61be4..d9916d9303 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.h +++ b/src/objective-c/GRPCClient/private/GRPCHost.h @@ -37,6 +37,7 @@ struct grpc_channel_credentials; @property(nonatomic) grpc_compression_algorithm compressAlgorithm; @property(nonatomic) int keepaliveInterval; @property(nonatomic) int keepaliveTimeout; +@property(nonatomic) id logContext; /** The following properties should only be modified for testing: */ diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index c3ea9afc37..f4b933751f 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -18,7 +18,6 @@ #import "GRPCHost.h" -#import <GRPCClient/GRPCCall+MobileLog.h> #import <GRPCClient/GRPCCall.h> #include <grpc/grpc.h> #include <grpc/grpc_security.h> @@ -50,7 +49,9 @@ static NSMutableDictionary *kHostCache; if (_channelCreds != nil) { grpc_channel_credentials_release(_channelCreds); } +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor unregisterObserver:self]; +#endif } // Default initializer. @@ -85,7 +86,9 @@ static NSMutableDictionary *kHostCache; kHostCache[address] = self; _compressAlgorithm = GRPC_COMPRESS_NONE; } +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)]; +#endif } return self; } @@ -126,6 +129,14 @@ static NSMutableDictionary *kHostCache; completionQueue:queue]; } +- (NSData *)nullTerminatedDataWithString:(NSString *)string { + // dataUsingEncoding: does not return a null-terminated string. + NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + NSMutableData *nullTerminated = [NSMutableData dataWithData:data]; + [nullTerminated appendBytes:"\0" length:1]; + return nullTerminated; +} + - (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts withPrivateKey:(nullable NSString *)pemPrivateKey withCertChain:(nullable NSString *)pemCertChain @@ -147,13 +158,12 @@ static NSMutableDictionary *kHostCache; kDefaultRootsError = error; return; } - kDefaultRootsASCII = - [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + kDefaultRootsASCII = [self nullTerminatedDataWithString:contentInUTF8]; }); NSData *rootsASCII; if (pemRootCerts != nil) { - rootsASCII = [pemRootCerts dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + rootsASCII = [self nullTerminatedDataWithString:pemRootCerts]; } else { if (kDefaultRootsASCII == nil) { if (errorPtr) { @@ -176,10 +186,8 @@ static NSMutableDictionary *kHostCache; creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL); } else { grpc_ssl_pem_key_cert_pair key_cert_pair; - NSData *privateKeyASCII = - [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; - NSData *certChainASCII = - [pemCertChain dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + NSData *privateKeyASCII = [self nullTerminatedDataWithString:pemPrivateKey]; + NSData *certChainASCII = [self nullTerminatedDataWithString:pemCertChain]; key_cert_pair.private_key = privateKeyASCII.bytes; key_cert_pair.cert_chain = certChainASCII.bytes; creds = grpc_ssl_credentials_create(rootsASCII.bytes, &key_cert_pair, NULL); @@ -223,9 +231,9 @@ static NSMutableDictionary *kHostCache; args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithInt:_keepaliveTimeout]; } - id logConfig = [GRPCCall logConfig]; - if (logConfig != nil) { - args[@GRPC_ARG_MOBILE_LOG_CONFIG] = logConfig; + id logContext = self.logContext; + if (logContext != nil) { + args[@GRPC_ARG_MOBILE_LOG_CONTEXT] = logContext; } if (useCronet) { diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index ab7159cda2..cdd1c6c8f7 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -325,6 +325,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Sample/Info.plist; + LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.grpc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -337,6 +338,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Sample/Info.plist; + LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.grpc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme b/src/objective-c/examples/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme index d399e22e46..e356ea22a6 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme @@ -42,7 +42,7 @@ </AdditionalOptions> </TestAction> <LaunchAction - buildConfiguration = "Debug" + buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" diff --git a/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj b/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj index 6a4c3519d6..7a03f9b41a 100644 --- a/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj @@ -99,7 +99,6 @@ 5EC49F8D2043E46B00ED189A /* Sources */, 5EC49F8E2043E46B00ED189A /* Frameworks */, 5EC49F8F2043E46B00ED189A /* Resources */, - 9F67C72B6B6BAF2781078886 /* [CP] Embed Pods Frameworks */, 735516C793AF7394FBB83B7F /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -194,21 +193,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9F67C72B6B6BAF2781078886 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ConnectivityTestingApp/Pods-ConnectivityTestingApp-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -284,6 +268,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + "GRPC_CFSTREAM=1", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; diff --git a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m index 88780e39f0..3c77fe2f2c 100644 --- a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m +++ b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m @@ -35,7 +35,9 @@ NSString *host = @"grpc-test.sandbox.googleapis.com"; - (void)viewDidLoad { [super viewDidLoad]; +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(reachabilityChanged:)]; +#endif } - (void)reachabilityChanged:(NSNotification *)note { diff --git a/src/objective-c/tests/Connectivity/Podfile b/src/objective-c/tests/Connectivity/Podfile index cdbc6dde59..c7127b3e78 100644 --- a/src/objective-c/tests/Connectivity/Podfile +++ b/src/objective-c/tests/Connectivity/Podfile @@ -5,9 +5,9 @@ platform :ios, '8.0' GRPC_LOCAL_SRC = '../../../..' target 'ConnectivityTestingApp' do - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC/CFStream', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core/CFStream-Implementation', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC/CFStream', :path => GRPC_LOCAL_SRC pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf" pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 5cd0231db7..d9186561c3 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -525,7 +525,8 @@ static GRPCProtoMethod *kFullDuplexCallMethod; - (void)testErrorCode { int port = [self findFreePort]; NSString *const kDummyAddress = [NSString stringWithFormat:@"localhost:%d", port]; - __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; + __weak XCTestExpectation *completion = + [self expectationWithDescription:@"Received correct error code."]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kDummyAddress path:kEmptyCallMethod.HTTPPath diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index b6e389715a..3c2a34fb49 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -37,6 +37,27 @@ GRPC_LOCAL_SRC = '../../..' end %w( + InteropTestsRemoteCFStream + InteropTestsLocalSSLCFStream + InteropTestsLocalCleartextCFStream +).each do |target_name| + target target_name do + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true + + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + + pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + + pod 'gRPC/CFStream', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core/CFStream-Implementation', :path => GRPC_LOCAL_SRC + pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true + pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true + end +end + +%w( CoreCronetEnd2EndTests CronetUnitTests ).each do |target_name| @@ -65,7 +86,7 @@ end # TODO(jcanizales): Send a PR to Cocoapods to get rid of this need. pre_install do |installer| # This is the gRPC-Core podspec object, as initialized by its podspec file. - grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec # Copied from gRPC-Core.podspec, except for the adjusted src_root: src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}" @@ -96,7 +117,11 @@ post_install do |installer| # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void # function" warning config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1' + if target.name.include?('CFStream') + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CFSTREAM=1' + else + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1' + end end end @@ -104,7 +129,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if target.name == 'gRPC' + if target.name == 'gRPC' || target.name.start_with?('gRPC.') target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index e0f220eaee..8ff4633582 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -13,11 +13,18 @@ 16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */; }; 20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */; }; 333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */; }; - 3D7C85F6AA68C4A205E3BA16 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */; }; 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */; }; 5E8A5DA91D3840B4000F8BC4 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; 5EAD6D271E27047400002378 /* CronetUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.m */; }; 5EAD6D291E27047400002378 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; + 5EC5E42B2081782C000EF4AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; + 5EC5E42C20817832000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 5EC5E43B208185A7000EF4AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; + 5EC5E43C208185AD000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 5EC5E43D208185B0000EF4AD /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; + 5EC5E44C208185EC000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; + 5EC5E44D208185F0000EF4AD /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; + 5EC5E44E20818948000EF4AD /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; 5EE84BF41D4717E40050C6CC /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5EE84BF61D4717E40050C6CC /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; 5EE84BFE1D471D400050C6CC /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; @@ -44,6 +51,9 @@ 63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; 63E240CE1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 63E240D01B6C63DC005F3B0E /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 91D4B3C85B6D8562F409CB48 /* libPods-InteropTestsLocalSSLCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */; }; + BC111C80CBF7068B62869352 /* libPods-InteropTestsRemoteCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */; }; + C3D6F4270A2FFF634D8849ED /* libPods-InteropTestsLocalCleartextCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */; }; F15EF7852DC70770EFDB1D2C /* libPods-AllTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */; }; /* End PBXBuildFile section */ @@ -120,31 +130,41 @@ /* Begin PBXFileReference section */ 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.release.xcconfig"; sourceTree = "<group>"; }; - 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig"; sourceTree = "<group>"; }; 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = "<group>"; }; 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; }; + 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartextCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.debug.xcconfig"; sourceTree = "<group>"; }; 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.cronet.xcconfig"; sourceTree = "<group>"; }; 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.test.xcconfig"; sourceTree = "<group>"; }; 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; sourceTree = "<group>"; }; 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.test.xcconfig"; sourceTree = "<group>"; }; + 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.release.xcconfig"; sourceTree = "<group>"; }; + 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.debug.xcconfig"; sourceTree = "<group>"; }; 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.cronet.xcconfig"; sourceTree = "<group>"; }; 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.release.xcconfig"; sourceTree = "<group>"; }; + 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; sourceTree = "<group>"; }; 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; sourceTree = "<group>"; }; + 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; sourceTree = "<group>"; }; + 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; sourceTree = "<group>"; }; 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.release.xcconfig"; sourceTree = "<group>"; }; 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.cronet.xcconfig"; sourceTree = "<group>"; }; 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.release.xcconfig"; sourceTree = "<group>"; }; 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.debug.xcconfig"; sourceTree = "<group>"; }; + 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; sourceTree = "<group>"; }; 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = "<group>"; }; 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = "<group>"; }; 5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreCronetEnd2EndTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = "<group>"; }; + 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = "<group>"; }; 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EAD6D261E27047400002378 /* CronetUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CronetUnitTests.m; sourceTree = "<group>"; }; 5EAD6D281E27047400002378 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; }; + 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalCleartextCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalSSLCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteWithCronet.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemoteWithCronet.m; sourceTree = "<group>"; }; 5EE84BF51D4717E40050C6CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; @@ -169,14 +189,17 @@ 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.test.xcconfig"; sourceTree = "<group>"; }; 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.cronet.xcconfig"; sourceTree = "<group>"; }; 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = "<group>"; }; + 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = "<group>"; }; + 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = "<group>"; }; + 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; sourceTree = "<group>"; }; 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteWithCronet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - A0361771A855917162911180 /* Pods-Tests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.test.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.test.xcconfig"; sourceTree = "<group>"; }; A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.test.xcconfig"; sourceTree = "<group>"; }; AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.cronet.xcconfig"; sourceTree = "<group>"; }; AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.release.xcconfig"; sourceTree = "<group>"; }; B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.test.xcconfig"; sourceTree = "<group>"; }; B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.debug.xcconfig"; sourceTree = "<group>"; }; + C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.test.xcconfig"; sourceTree = "<group>"; }; C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.test.xcconfig"; sourceTree = "<group>"; }; @@ -186,9 +209,10 @@ DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.debug.xcconfig"; sourceTree = "<group>"; }; E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.debug.xcconfig"; sourceTree = "<group>"; }; E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.release.xcconfig"; sourceTree = "<group>"; }; - E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = "<group>"; }; + E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; sourceTree = "<group>"; }; E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.cronet.xcconfig"; sourceTree = "<group>"; }; - F671D4CAD2864FB203B920B4 /* Pods-Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.cronet.xcconfig"; sourceTree = "<group>"; }; + F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSLCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CoreCronetEnd2EndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; }; @@ -213,6 +237,30 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5EC5E41E208177CC000EF4AD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BC111C80CBF7068B62869352 /* libPods-InteropTestsRemoteCFStream.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E42E2081856B000EF4AD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3D6F4270A2FFF634D8849ED /* libPods-InteropTestsLocalCleartextCFStream.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E43F208185CE000EF4AD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 91D4B3C85B6D8562F409CB48 /* libPods-InteropTestsLocalSSLCFStream.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EE84BEE1D4717E40050C6CC /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -235,7 +283,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3D7C85F6AA68C4A205E3BA16 /* libPods-Tests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -291,6 +338,9 @@ FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */, 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */, C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */, + F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */, + 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */, + F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */, ); name = Frameworks; sourceTree = "<group>"; @@ -310,8 +360,6 @@ E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */, 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */, 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */, - 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */, - E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */, 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */, 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */, 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */, @@ -323,7 +371,6 @@ 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */, 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */, 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */, - F671D4CAD2864FB203B920B4 /* Pods-Tests.cronet.xcconfig */, 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */, 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */, 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */, @@ -335,7 +382,18 @@ A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */, 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */, 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */, - A0361771A855917162911180 /* Pods-Tests.test.xcconfig */, + 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */, + C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */, + 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */, + 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */, + 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */, + E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */, + 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */, + 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */, + 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */, + 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */, + 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */, + 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */, ); name = Pods; sourceTree = "<group>"; @@ -392,6 +450,9 @@ 5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */, 5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */, 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */, + 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */, + 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */, + 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */, ); name = Products; sourceTree = "<group>"; @@ -433,7 +494,6 @@ 5E8A5DA11D3840B4000F8BC4 /* Frameworks */, 5E8A5DA21D3840B4000F8BC4 /* Resources */, E63468C760D0724F18861822 /* [CP] Embed Pods Frameworks */, - 6DFE9E77CAB5760196D79E0F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -454,7 +514,6 @@ 5EAD6D211E27047400002378 /* Frameworks */, 5EAD6D221E27047400002378 /* Resources */, A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */, - 051806D6A59B19C8A0B76BED /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -466,6 +525,63 @@ productReference = 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */; + buildPhases = ( + 483CDBBAEAEFCB530ADDDDD5 /* [CP] Check Pods Manifest.lock */, + 5EC5E41D208177CC000EF4AD /* Sources */, + 5EC5E41E208177CC000EF4AD /* Frameworks */, + 5EC5E41F208177CC000EF4AD /* Resources */, + 95FBC48B743503845678584F /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = InteropTestsRemoteCFStream; + productName = InteropTestsRemoteCFStream; + productReference = 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 5EC5E4302081856B000EF4AD /* InteropTestsLocalCleartextCFStream */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5EC5E4362081856C000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartextCFStream" */; + buildPhases = ( + 252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */, + 5EC5E42D2081856B000EF4AD /* Sources */, + 5EC5E42E2081856B000EF4AD /* Frameworks */, + 5EC5E42F2081856B000EF4AD /* Resources */, + A023FB55205A7EA37D413549 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = InteropTestsLocalCleartextCFStream; + productName = InteropTestsLocalCleartextCFStream; + productReference = 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 5EC5E441208185CE000EF4AD /* InteropTestsLocalSSLCFStream */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5EC5E447208185CE000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSLCFStream" */; + buildPhases = ( + F3D5B2CDA172580341682830 /* [CP] Check Pods Manifest.lock */, + 5EC5E43E208185CE000EF4AD /* Sources */, + 5EC5E43F208185CE000EF4AD /* Frameworks */, + 5EC5E440208185CE000EF4AD /* Resources */, + 4EB2FFF40BB00AD0C545D7EF /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = InteropTestsLocalSSLCFStream; + productName = InteropTestsLocalSSLCFStream; + productReference = 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 5EE84BF01D4717E40050C6CC /* InteropTestsRemoteWithCronet */ = { isa = PBXNativeTarget; buildConfigurationList = 5EE84BFB1D4717E40050C6CC /* Build configuration list for PBXNativeTarget "InteropTestsRemoteWithCronet" */; @@ -496,7 +612,6 @@ 63423F411B150A5F006CF63C /* Frameworks */, 63423F421B150A5F006CF63C /* Resources */, A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */, - 5F14F59509E10C2852014F9E /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -512,11 +627,9 @@ isa = PBXNativeTarget; buildConfigurationList = 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */; buildPhases = ( - 796680C7599CB4ED736DD62A /* [CP] Check Pods Manifest.lock */, 635697C31B14FC11007A7283 /* Sources */, 635697C41B14FC11007A7283 /* Frameworks */, 635697C51B14FC11007A7283 /* CopyFiles */, - AEEBFC914CBAEE347382E8C4 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -535,7 +648,6 @@ 63DC840F1BE15179000708E8 /* Sources */, 63DC84101BE15179000708E8 /* Frameworks */, 63DC84111BE15179000708E8 /* Resources */, - 4F5690DC0E6AD6663FE78B8B /* [CP] Embed Pods Frameworks */, C977426A8727267BBAC7D48E /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -556,7 +668,6 @@ 63DC841F1BE15267000708E8 /* Sources */, 63DC84201BE15267000708E8 /* Frameworks */, 63DC84211BE15267000708E8 /* Resources */, - 900B6EDD4D16BE7D765C3885 /* [CP] Embed Pods Frameworks */, C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -577,7 +688,6 @@ 63DC84301BE15294000708E8 /* Sources */, 63DC84311BE15294000708E8 /* Frameworks */, 63DC84321BE15294000708E8 /* Resources */, - C591129ACE9F6CC5EE03FCDE /* [CP] Embed Pods Frameworks */, 693DD0B453431D64EA24FD66 /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -598,7 +708,6 @@ 63DC843F1BE152B5000708E8 /* Sources */, 63DC84401BE152B5000708E8 /* Frameworks */, 63DC84411BE152B5000708E8 /* Resources */, - A8E3AC66DF770B774114A30E /* [CP] Embed Pods Frameworks */, 8AD3130D3C58A0FB32FF2A36 /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -626,6 +735,18 @@ 5EAD6D231E27047400002378 = { CreatedOnToolsVersion = 7.3.1; }; + 5EC5E420208177CC000EF4AD = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + 5EC5E4302081856B000EF4AD = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + 5EC5E441208185CE000EF4AD = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; 5EE84BF01D4717E40050C6CC = { CreatedOnToolsVersion = 7.3.1; }; @@ -670,6 +791,9 @@ 5E8A5DA31D3840B4000F8BC4 /* CoreCronetEnd2EndTests */, 5EE84BF01D4717E40050C6CC /* InteropTestsRemoteWithCronet */, 5EAD6D231E27047400002378 /* CronetUnitTests */, + 5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */, + 5EC5E4302081856B000EF4AD /* InteropTestsLocalCleartextCFStream */, + 5EC5E441208185CE000EF4AD /* InteropTestsLocalSSLCFStream */, ); }; /* End PBXProject section */ @@ -689,6 +813,28 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5EC5E41F208177CC000EF4AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E42F2081856B000EF4AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E440208185CE000EF4AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5EC5E44E20818948000EF4AD /* TestCertificates.bundle in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EE84BEF1D4717E40050C6CC /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -736,22 +882,22 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 051806D6A59B19C8A0B76BED /* [CP] Copy Pods Resources */ = { + 252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalCleartextCFStream-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 31F8D1C407195CBF0C02929B /* [CP] Embed Pods Frameworks */ = { @@ -772,7 +918,7 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 4C406327D3907A5E5FBA8AC9 /* [CP] Check Pods Manifest.lock */ = { + 483CDBBAEAEFCB530ADDDDD5 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -783,29 +929,14 @@ ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemote-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemoteCFStream-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 4F5690DC0E6AD6663FE78B8B /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 5C20DCCB71C3991E6FE78C22 /* [CP] Check Pods Manifest.lock */ = { + 4C406327D3907A5E5FBA8AC9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -816,53 +947,56 @@ ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSL-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemote-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 5F14F59509E10C2852014F9E /* [CP] Embed Pods Frameworks */ = { + 4EB2FFF40BB00AD0C545D7EF /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-CFStream/gRPCCertificates.bundle", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 693DD0B453431D64EA24FD66 /* [CP] Copy Pods Resources */ = { + 5C20DCCB71C3991E6FE78C22 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSL-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 6DFE9E77CAB5760196D79E0F /* [CP] Copy Pods Resources */ = { + 693DD0B453431D64EA24FD66 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-resources.sh", + "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -871,7 +1005,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; showEnvVarsInLog = 0; }; 7418AC7B3844B29E48D24FC7 /* [CP] Check Pods Manifest.lock */ = { @@ -892,24 +1026,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 796680C7599CB4ED736DD62A /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; 80E2DDD2EC04A4009F45E933 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -946,21 +1062,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 900B6EDD4D16BE7D765C3885 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 914ADDD7106BA9BB8A7E569F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -979,14 +1080,14 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */ = { + 95FBC48B743503845678584F /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", + "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-CFStream/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -994,58 +1095,61 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; - A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */ = { + A023FB55205A7EA37D413549 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", + "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-CFStream/gRPCCertificates.bundle", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; - A8E3AC66DF770B774114A30E /* [CP] Embed Pods Frameworks */ = { + A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - AEEBFC914CBAEE347382E8C4 /* [CP] Copy Pods Resources */ = { + A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", + "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; B2986CEEE8CDD4901C97598B /* [CP] Check Pods Manifest.lock */ = { @@ -1102,21 +1206,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh\"\n"; showEnvVarsInLog = 0; }; - C591129ACE9F6CC5EE03FCDE /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; C977426A8727267BBAC7D48E /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1171,6 +1260,24 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + F3D5B2CDA172580341682830 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSLCFStream-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; F58F17E425446B15028B9F74 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1208,6 +1315,34 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5EC5E41D208177CC000EF4AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5EC5E42B2081782C000EF4AD /* InteropTestsRemote.m in Sources */, + 5EC5E42C20817832000EF4AD /* InteropTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E42D2081856B000EF4AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5EC5E43B208185A7000EF4AD /* InteropTestsLocalCleartext.m in Sources */, + 5EC5E43D208185B0000EF4AD /* GRPCClientTests.m in Sources */, + 5EC5E43C208185AD000EF4AD /* InteropTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EC5E43E208185CE000EF4AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5EC5E44D208185F0000EF4AD /* InteropTestsLocalSSL.m in Sources */, + 5EC5E44C208185EC000EF4AD /* InteropTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EE84BED1D4717E40050C6CC /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1350,6 +1485,7 @@ "HOST_PORT_LOCALSSL=$(HOST_PORT_LOCALSSL)", "HOST_PORT_LOCAL=$(HOST_PORT_LOCAL)", "HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)", + "GRPC_TEST_OBJC=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1368,7 +1504,6 @@ }; 5E1228991E4D400F00E8504F /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A0361771A855917162911180 /* Pods-Tests.test.xcconfig */; buildSettings = { GCC_TREAT_WARNINGS_AS_ERRORS = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1668,7 +1803,6 @@ }; 5EC3C7A11D4FC18C000330E2 /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F671D4CAD2864FB203B920B4 /* Pods-Tests.cronet.xcconfig */; buildSettings = { GCC_TREAT_WARNINGS_AS_ERRORS = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1797,6 +1931,360 @@ }; name = Cronet; }; + 5EC5E426208177CC000EF4AD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5EC5E427208177CC000EF4AD /* Test */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Test; + }; + 5EC5E428208177CC000EF4AD /* Cronet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Cronet; + }; + 5EC5E429208177CC000EF4AD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5EC5E4372081856C000EF4AD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5EC5E4382081856C000EF4AD /* Test */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Test; + }; + 5EC5E4392081856C000EF4AD /* Cronet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Cronet; + }; + 5EC5E43A2081856C000EF4AD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5EC5E448208185CE000EF4AD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5EC5E449208185CE000EF4AD /* Test */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Test; + }; + 5EC5E44A208185CE000EF4AD /* Cronet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Cronet; + }; + 5EC5E44B208185CE000EF4AD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 5EE84BF91D4717E40050C6CC /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */; @@ -1953,7 +2441,6 @@ }; 635697DC1B14FC11007A7283 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */; buildSettings = { GCC_TREAT_WARNINGS_AS_ERRORS = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1963,7 +2450,6 @@ }; 635697DD1B14FC11007A7283 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */; buildSettings = { GCC_TREAT_WARNINGS_AS_ERRORS = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2100,6 +2586,39 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5EC5E426208177CC000EF4AD /* Debug */, + 5EC5E427208177CC000EF4AD /* Test */, + 5EC5E428208177CC000EF4AD /* Cronet */, + 5EC5E429208177CC000EF4AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5EC5E4362081856C000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartextCFStream" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5EC5E4372081856C000EF4AD /* Debug */, + 5EC5E4382081856C000EF4AD /* Test */, + 5EC5E4392081856C000EF4AD /* Cronet */, + 5EC5E43A2081856C000EF4AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5EC5E447208185CE000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSLCFStream" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5EC5E448208185CE000EF4AD /* Debug */, + 5EC5E449208185CE000EF4AD /* Test */, + 5EC5E44A208185CE000EF4AD /* Cronet */, + 5EC5E44B208185CE000EF4AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 5EE84BFB1D4717E40050C6CC /* Build configuration list for PBXNativeTarget "InteropTestsRemoteWithCronet" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme index a2560fee02..b0bb933764 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -66,6 +67,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme index 6d85b62fab..510115fc75 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -57,6 +58,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme new file mode 100644 index 0000000000..fe766de928 --- /dev/null +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Test" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5EC5E4302081856B000EF4AD" + BuildableName = "InteropTestsLocalCleartextCFStream.xctest" + BlueprintName = "InteropTestsLocalCleartextCFStream" + ReferencedContainer = "container:Tests.xcodeproj"> + </BuildableReference> + <SkippedTests> + <Test + Identifier = "InteropTests"> + </Test> + </SkippedTests> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme new file mode 100644 index 0000000000..bd66327649 --- /dev/null +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Test" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5EC5E441208185CE000EF4AD" + BuildableName = "InteropTestsLocalSSLCFStream.xctest" + BlueprintName = "InteropTestsLocalSSLCFStream" + ReferencedContainer = "container:Tests.xcodeproj"> + </BuildableReference> + <SkippedTests> + <Test + Identifier = "InteropTests"> + </Test> + </SkippedTests> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme index 412bf6a014..48837e57f9 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -60,6 +61,7 @@ buildConfiguration = "Test" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme new file mode 100644 index 0000000000..33a5ded038 --- /dev/null +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Test" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5EC5E420208177CC000EF4AD" + BuildableName = "InteropTestsRemoteCFStream.xctest" + BlueprintName = "InteropTestsRemoteCFStream" + ReferencedContainer = "container:Tests.xcodeproj"> + </BuildableReference> + <SkippedTests> + <Test + Identifier = "InteropTests"> + </Test> + </SkippedTests> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/src/objective-c/tests/analyze_link_map.py b/src/objective-c/tests/analyze_link_map.py deleted file mode 100755 index 48e3441087..0000000000 --- a/src/objective-c/tests/analyze_link_map.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script analyzes link map file generated by Xcode. It calculates and -# prints out the sizes of each dependent library and the total sizes of the -# symbols. -# The script takes one parameter, which is the path to the link map file. - -import sys -import re - -table_tag = {} -state = "start" - -table_stats_symbol = {} -table_stats_dead = {} -section_total_size = 0 -symbol_total_size = 0 - - -file_import = sys.argv[1] -lines = list(open(file_import)) -for line in lines: - line_stripped = line[:-1] - if "# Object files:" == line_stripped: - state = "object" - continue - elif "# Sections:" == line_stripped: - state = "section" - continue - elif "# Symbols:" == line_stripped: - state = "symbol" - continue - elif "# Dead Stripped Symbols:" == line_stripped: - state = "dead" - continue - - if state == "object": - segs = re.search('(\[ *[0-9]*\]) (.*)', line_stripped) - table_tag[segs.group(1)] = segs.group(2) - - if state == "section": - if len(line_stripped) == 0 or line_stripped[0] == '#': - continue - segs = re.search('^(.+?)\s+(.+?)\s+.*', line_stripped) - section_total_size += int(segs.group(2), 16) - - if state == "symbol": - if len(line_stripped) == 0 or line_stripped[0] == '#': - continue - segs = re.search('^.+?\s+(.+?)\s+(\[.+?\]).*', line_stripped) - target = table_tag[segs.group(2)] - target_stripped = re.search('^(.*?)(\(.+?\))?$', target).group(1) - size = int(segs.group(1), 16) - if not target_stripped in table_stats_symbol: - table_stats_symbol[target_stripped] = 0 - table_stats_symbol[target_stripped] += size - -print("Sections total size: %d" % section_total_size) - -for target in table_stats_symbol: - print(target) - print(table_stats_symbol[target]) - symbol_total_size += table_stats_symbol[target] - -print("Symbols total size: %d" % symbol_total_size) diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index 985d55f3cc..1eace541e6 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -42,6 +42,9 @@ xcodebuild \ build \ -workspace *.xcworkspace \ -scheme $SCHEME \ - -destination name="iPhone 6" \ + -destination generic/platform=iOS \ + -derivedDataPath Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v "^$" - diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 2fe2326207..9dde07d55c 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -53,7 +53,7 @@ while [ $retries -lt 3 ]; do out=$(xcodebuild \ -workspace Tests.xcworkspace \ -scheme AllTests \ - -destination name="iPhone 6" \ + -destination name="iPhone 8" \ HOST_PORT_LOCALSSL=localhost:5051 \ HOST_PORT_LOCAL=localhost:5050 \ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ @@ -83,7 +83,7 @@ echo "TIME: $(date)" xcodebuild \ -workspace Tests.xcworkspace \ -scheme CoreCronetEnd2EndTests \ - -destination name="iPhone 6" \ + -destination name="iPhone 8" \ test \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v '^$' \ @@ -113,7 +113,7 @@ echo "TIME: $(date)" xcodebuild \ -workspace Tests.xcworkspace \ -scheme CronetUnitTests \ - -destination name="iPhone 6" \ + -destination name="iPhone 8" \ test \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v '^$' \ @@ -123,11 +123,44 @@ echo "TIME: $(date)" xcodebuild \ -workspace Tests.xcworkspace \ -scheme InteropTestsRemoteWithCronet \ - -destination name="iPhone 6" \ + -destination name="iPhone 8" \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + +echo "TIME: $(date)" +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme InteropTestsRemoteCFStream \ + -destination name="iPhone 8" \ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v '^$' \ | egrep -v "(GPBDictionary|GPBArray)" - +echo "TIME: $(date)" +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme InteropTestsLocalCleartextCFStream \ + -destination name="iPhone 8" \ + HOST_PORT_LOCAL=localhost:5050 \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + +echo "TIME: $(date)" +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme InteropTestsLocalSSLCFStream \ + -destination name="iPhone 8" \ + HOST_PORT_LOCALSSL=localhost:5051 \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + exit 0 diff --git a/src/php/README.md b/src/php/README.md index 11f99e134c..5e9fa38763 100644 --- a/src/php/README.md +++ b/src/php/README.md @@ -2,11 +2,15 @@ # Overview This directory contains source code for PHP implementation of gRPC layered on -shared C library. +shared C library. The same installation guides with more examples and +tutorials can be seen at [grpc.io](https://grpc.io/docs/quickstart/php.html). +gRPC PHP installation instructions for Google Cloud Platform is in +[cloud.google.com](https://cloud.google.com/php/grpc). ## Environment -**Prerequisite:** +### Prerequisite: + * `php` 5.5 or above, 7.0 or above * `pecl` * `composer` @@ -25,6 +29,10 @@ For PHP7: ```sh $ sudo apt-get install php7.0 php7.0-dev php-pear phpunit ``` +or +```sh +$ sudo apt-get install php php-dev php-pear phpunit +``` **Install PHP and PECL on CentOS/RHEL 7:** ```sh @@ -33,8 +41,9 @@ $ sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm $ sudo yum install php56w php56w-devel php-pear phpunit gcc zlib-devel ``` -**Install PECL on Mac:** +**Install PHP and PECL on Mac:** ```sh +$ brew install homebrew/php/php56-grpc $ curl -O http://pear.php.net/go-pear.phar $ sudo php -d detect_unicode=0 go-pear.phar ``` @@ -52,50 +61,33 @@ $ chmod +x phpunit-old.phar $ sudo mv phpunit-old.phar /usr/bin/phpunit ``` -## Quick Install +## Install the gRPC PHP extension -**Install the gRPC PHP extension** +There are two ways to install gRPC PHP extension. +* `pecl` +* `build from source` + +### Using PECL ```sh sudo pecl install grpc ``` -This will compile and install the gRPC PHP extension into the standard PHP -extension directory. You should be able to run the [unit tests](#unit-tests), -with the PHP extension installed. - -Note: For users on CentOS/RHEL 6, unfortunately this step won't work. Please -follow the instructions below to compile the extension from source. - - -**Update php.ini** - -Add this line to your `php.ini` file, e.g. `/etc/php5/cli/php.ini` +or specific version ```sh -extension=grpc.so -``` - - -**Add the gRPC PHP library as a Composer dependency** - -You need to add this to your project's `composer.json` file. - -``` - "require": { - "grpc/grpc": "v1.1.0" - } +sudo pecl install grpc-1.12.0 ``` -To run tests with generated stub code from `.proto` files, you will also need -the `composer` and `protoc` binaries. You can find out how to get these -[below](#generated-code-tests). +Note: for users on CentOS/RHEL 6, unfortunately this step won’t work. +Please follow the instructions below to compile the PECL extension from source. +#### Install on Windows -## Build from Source +You can download the pre-compiled gRPC extension from the PECL +[website](https://pecl.php.net/package/grpc) - -### gRPC C core library +### Build from Source with gRPC C core library Clone this repository @@ -103,16 +95,16 @@ Clone this repository $ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc ``` -Build and install the gRPC C core library +#### Build and install the gRPC C core library ```sh $ cd grpc -$ git pull --recurse-submodules && git submodule update --init --recursive +$ git submodule update --init $ make $ sudo make install ``` -### gRPC PHP extension +#### Build and install gRPC PHP extension Compile the gRPC PHP extension @@ -124,44 +116,69 @@ $ make $ sudo make install ``` -## Unit Tests +This will compile and install the gRPC PHP extension into the +standard PHP extension directory. You should be able to run +the [unit tests](#unit-tests), with the PHP extension installed. -You will need the source code to run tests + +### Update php.ini + +After installing the gRPC extension, make sure you add this line +to your `php.ini` file, (e.g. `/etc/php5/cli/php.ini`, +`/etc/php5/apache2/php.ini`, or `/usr/local/etc/php/5.6/php.ini`), +depending on where your PHP installation is. ```sh -$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc -$ cd grpc -$ git pull --recurse-submodules && git submodule update --init --recursive +extension=grpc.so ``` -Run unit tests +**Add the gRPC PHP library as a Composer dependency** -```sh -$ cd grpc/src/php -$ ./bin/run_tests.sh +You need to add this to your project's `composer.json` file. + +``` + "require": { + "grpc/grpc": "v1.12.0" + } ``` -## Generated Code Tests +To run tests with generated stub code from `.proto` files, you will also +need the `composer` and `protoc` binaries. You can find out how to get these below. -This section specifies the prerequisites for running the generated code tests, -as well as how to run the tests themselves. +## Install other prerequisites for both Mac OS X and Linux -### Composer +* `protoc: protobuf compiler` +* `protobuf.so: protobuf runtime library` +* `grpc_php_plugin: Generates PHP gRPC service interface out of Protobuf IDL` -Install the runtime dependencies via `composer install`. +### Install Protobuf compiler -```sh -$ cd grpc/src/php -$ composer install -``` +If you don't have it already, you need to install the protobuf compiler +`protoc`, version 3.5.0+ (the newer the better) for the current gRPC version. +If you installed already, make the protobuf version is compatible to the +grpc version you installed. If you build grpc.so from the souce, you can check +the version of grpc inside package.xml file. -### Protobuf compiler +The compatibility between the grpc and protobuf version is listed as table below: -Again if you don't have it already, you need to install the protobuf compiler -`protoc`, version 3.1.0+ (the newer the better). +grpc | protobuf +--- | --- +v1.0.0 | 3.0.0(GA) +v1.0.1 | 3.0.2 +v1.1.0 | 3.1.0 +v1.2.0 | 3.2.0 +v1.2.0 | 3.2.0 +v1.3.4 | 3.3.0 +v1.3.5 | 3.2.0 +v1.4.0 | 3.3.0 +v1.6.0 | 3.4.0 +v1.8.0 | 3.5.0 +v1.12.0 | 3.5.2 If `protoc` hasn't been installed, you can download the `protoc` binaries from [the protocol buffers Github repository](https://github.com/google/protobuf/releases). +Then unzip this file and update the environment variable `PATH` to include the path to +the protoc binary file. If you really must compile `protoc` from source, you can run the following commands, but this is risky because there is no easy way to uninstall / @@ -173,32 +190,44 @@ $ ./autogen.sh && ./configure && make $ sudo make install ``` - ### Protobuf Runtime library -There are two protobuf runtime libraries to choose from. They are idenfical in terms of APIs offered. +There are two protobuf runtime libraries to choose from. They are identical +in terms of APIs offered. The C implementation provides better performance, +while the native implementation is easier to install. Make sure the installed +protobuf version works with grpc version. -1. C implementation (for better performance) +#### 1. C implementation (for better performance) ``` sh $ sudo pecl install protobuf ``` +or specific version -2. PHP implementation (for easier installation) +``` sh +$ sudo pecl install protobuf-3.5.1.1 +``` +Add this to your `php.ini` file: + +```sh +extension=protobuf.so +``` + +#### 2. PHP implementation (for easier installation) Add this to your `composer.json` file: ``` "require": { - "google/protobuf": "^v3.3.0" + "google/protobuf": "^v3.5.0" } -``` - +``` ### PHP Protoc Plugin You need the gRPC PHP protoc plugin to generate the client stub classes. +It can generate server and client code from .proto service definitions. It should already been compiled when you run `make` from the root directory of this repo. The plugin can be found in the `bins/opt` directory. We are @@ -208,10 +237,47 @@ in the future. You can also just build the gRPC PHP protoc plugin by running: ```sh +$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc $ cd grpc +$ git submodule update --init $ make grpc_php_plugin ``` +Plugin may use the new feature of the new protobuf version, thus please also +make sure that the protobuf version installed is compatible with the grpc version +you build this plugin. + +## Unit Tests + +You will need the source code to run tests + +```sh +$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc +$ cd grpc +$ git submodule update --init +``` + +Run unit tests + +```sh +$ cd grpc/src/php +$ ./bin/run_tests.sh +``` + +## Generated Code Tests + +This section specifies the prerequisites for running the generated code tests, +as well as how to run the tests themselves. + +### Composer + +Install the runtime dependencies via `composer install`. + +```sh +$ cd grpc/src/php +$ composer install +``` + ### Client Stub diff --git a/src/proto/grpc/testing/messages.proto b/src/proto/grpc/testing/messages.proto index 0b8c15711e..7b1b7286dc 100644 --- a/src/proto/grpc/testing/messages.proto +++ b/src/proto/grpc/testing/messages.proto @@ -27,7 +27,6 @@ message BoolValue { bool value = 1; } -// DEPRECATED, don't use. To be removed shortly. // The type of payload that should be returned. enum PayloadType { // Compressable text format. @@ -36,7 +35,6 @@ enum PayloadType { // A block of data, to simply increase gRPC message size. message Payload { - // DEPRECATED, don't use. To be removed shortly. // The type of data in body. PayloadType type = 1; // Primary contents of payload. @@ -52,7 +50,6 @@ message EchoStatus { // Unary request. message SimpleRequest { - // DEPRECATED, don't use. To be removed shortly. // Desired payload type in the response from the server. // If response_type is RANDOM, server randomly chooses one from other formats. PayloadType response_type = 1; @@ -131,7 +128,6 @@ message ResponseParameters { // Server-streaming request. message StreamingOutputCallRequest { - // DEPRECATED, don't use. To be removed shortly. // Desired payload type in the response from the server. // If response_type is RANDOM, the payload from each response in the stream // might be of different types. This is to simulate a mixed type of payload diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 0f31119467..996d075446 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1482,7 +1482,7 @@ def ssl_server_credentials(private_key_certificate_chain_pairs, A ServerCredentials for use with an SSL-enabled Server. Typically, this object is an argument to add_secure_port() method during server setup. """ - if len(private_key_certificate_chain_pairs) == 0: + if not private_key_certificate_chain_pairs: raise ValueError( 'At least one private key-certificate chain pair is required!') elif require_client_auth and root_certificates is None: @@ -1512,15 +1512,15 @@ def ssl_server_certificate_configuration(private_key_certificate_chain_pairs, A ServerCertificateConfiguration that can be returned in the certificate configuration fetching callback. """ - if len(private_key_certificate_chain_pairs) == 0: - raise ValueError( - 'At least one private key-certificate chain pair is required!') - else: + if private_key_certificate_chain_pairs: return ServerCertificateConfiguration( _cygrpc.server_certificate_config_ssl(root_certificates, [ _cygrpc.SslPemKeyCertPair(key, pem) for key, pem in private_key_certificate_chain_pairs ])) + else: + raise ValueError( + 'At least one private key-certificate chain pair is required!') def dynamic_ssl_server_credentials(initial_certificate_configuration, @@ -1656,9 +1656,11 @@ def server(thread_pool, A Server object. """ from grpc import _server # pylint: disable=cyclic-import - return _server.Server(thread_pool, () if handlers is None else handlers, () - if interceptors is None else interceptors, () if - options is None else options, maximum_concurrent_rpcs) + return _server.create_server(thread_pool, () + if handlers is None else handlers, () + if interceptors is None else interceptors, () + if options is None else options, + maximum_concurrent_rpcs) ################################### __all__ ################################# diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 2017d47130..e9246991df 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -24,6 +24,8 @@ from grpc import _grpcio_metadata from grpc._cython import cygrpc from grpc.framework.foundation import callable_util +_LOGGER = logging.getLogger(__name__) + _USER_AGENT = 'grpc-python/{}'.format(_grpcio_metadata.__version__) _EMPTY_FLAGS = 0 @@ -181,7 +183,7 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, except Exception: # pylint: disable=broad-except code = grpc.StatusCode.UNKNOWN details = 'Exception iterating requests!' - logging.exception(details) + _LOGGER.exception(details) call.cancel(_common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], details) _abort(state, code, details) @@ -190,7 +192,7 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, with state.condition: if state.code is None and not state.cancelled: if serialized_request is None: - code = grpc.StatusCode.INTERNAL # pylint: disable=redefined-variable-type + code = grpc.StatusCode.INTERNAL details = 'Exception serializing request!' call.cancel( _common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], @@ -811,10 +813,7 @@ def _poll_connectivity(state, channel, initial_try_to_connect): _common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[ connectivity]) if not state.delivering: - # NOTE(nathaniel): The field is only ever used as a - # sequence so it's fine that both lists and tuples are - # assigned to it. - callbacks = _deliveries(state) # pylint: disable=redefined-variable-type + callbacks = _deliveries(state) if callbacks: _spawn_delivery(state, callbacks) diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index 862987a0cd..8358cbec5b 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -20,6 +20,8 @@ import six import grpc from grpc._cython import cygrpc +_LOGGER = logging.getLogger(__name__) + CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = { cygrpc.ConnectivityState.idle: grpc.ChannelConnectivity.IDLE, @@ -73,7 +75,7 @@ def decode(b): try: return b.decode('utf8') except UnicodeDecodeError: - logging.exception('Invalid encoding on %s', b) + _LOGGER.exception('Invalid encoding on %s', b) return b.decode('latin1') @@ -84,7 +86,7 @@ def _transform(message, transformer, exception_message): try: return transformer(message) except Exception: # pylint: disable=broad-except - logging.exception(exception_message) + _LOGGER.exception(exception_message) return None diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi index 65de30884c..aecd3d7b11 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -15,10 +15,12 @@ cimport cpython +# TODO(https://github.com/grpc/grpc/issues/15662): Reform this. cdef void* _copy_pointer(void* pointer): return pointer +# TODO(https://github.com/grpc/grpc/issues/15662): Reform this. cdef void _destroy_pointer(void* pointer): pass diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi index eefc685c0b..f067d76fab 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi @@ -69,3 +69,6 @@ cdef class Channel: cdef grpc_arg_pointer_vtable _vtable cdef _ChannelState _state + + # TODO(https://github.com/grpc/grpc/issues/15662): Eliminate this. + cdef tuple _arguments diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 72e74e84ae..8c37a3cf85 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -390,6 +390,7 @@ cdef class Channel: def __cinit__( self, bytes target, object arguments, ChannelCredentials channel_credentials): + arguments = () if arguments is None else tuple(arguments) grpc_init() self._state = _ChannelState() self._vtable.copy = &_copy_pointer @@ -410,6 +411,7 @@ cdef class Channel: grpc_completion_queue_create_for_next(NULL)) self._state.c_connectivity_completion_queue = ( grpc_completion_queue_create_for_next(NULL)) + self._arguments = arguments def target(self): cdef char *c_target diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index 7e9ea33ca0..8d73215247 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -57,6 +57,11 @@ cdef class ChannelCredentials: cdef grpc_channel_credentials *c_credentials +cdef class SSLSessionCacheLRU: + + cdef grpc_ssl_session_cache *_cache + + cdef class SSLChannelCredentials(ChannelCredentials): cdef readonly object _pem_root_certificates diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index dff9097bf9..f4ccfbc016 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -17,6 +17,9 @@ cimport cpython import grpc import threading +from libc.stdint cimport uintptr_t + + def _spawn_callback_in_thread(cb_func, args): threading.Thread(target=cb_func, args=args).start() @@ -29,6 +32,7 @@ def set_async_callback_func(callback_func): def _spawn_callback_async(callback, args): async_callback_func(callback, args) + cdef class CallCredentials: cdef grpc_call_credentials *c(self): @@ -107,6 +111,21 @@ cdef class ChannelCredentials: raise NotImplementedError() +cdef class SSLSessionCacheLRU: + + def __cinit__(self, capacity): + grpc_init() + self._cache = grpc_ssl_session_cache_create_lru(capacity) + + def __int__(self): + return <uintptr_t>self._cache + + def __dealloc__(self): + if self._cache != NULL: + grpc_ssl_session_cache_destroy(self._cache) + grpc_shutdown() + + cdef class SSLChannelCredentials(ChannelCredentials): def __cinit__(self, pem_root_certificates, private_key, certificate_chain): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 2d6c900c54..cfefeaf938 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -131,6 +131,7 @@ cdef extern from "grpc/grpc.h": const char *GRPC_ARG_PRIMARY_USER_AGENT_STRING const char *GRPC_ARG_SECONDARY_USER_AGENT_STRING const char *GRPC_SSL_TARGET_NAME_OVERRIDE_ARG + const char *GRPC_SSL_SESSION_CACHE_ARG const char *GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM const char *GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL const char *GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET @@ -452,8 +453,16 @@ cdef extern from "grpc/grpc_security.h": # We don't care about the internals (and in fact don't know them) pass + + ctypedef struct grpc_ssl_session_cache: + # We don't care about the internals (and in fact don't know them) + pass + ctypedef void (*grpc_ssl_roots_override_callback)(char **pem_root_certs) + grpc_ssl_session_cache *grpc_ssl_session_cache_create_lru(size_t capacity) + void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache) + void grpc_set_ssl_roots_override_callback( grpc_ssl_roots_override_callback cb) nogil diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index f5688d08cd..f5688d08cd 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index f9a1b2856d..f9a1b2856d 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi index 53e06a1596..00a1b23a67 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi @@ -14,6 +14,7 @@ import logging +_LOGGER = logging.getLogger(__name__) # This function will ascii encode unicode string inputs if neccesary. # In Python3, unicode strings are the default str type. @@ -49,5 +50,5 @@ cdef str _decode(bytes bytestring): try: return bytestring.decode('utf8') except UnicodeDecodeError: - logging.exception('Invalid encoding on %s', bytestring) + _LOGGER.exception('Invalid encoding on %s', bytestring) return bytestring.decode('latin1') diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index ecd991685f..37b98ebbdb 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -51,6 +51,7 @@ class ChannelArgKey: default_authority = GRPC_ARG_DEFAULT_AUTHORITY primary_user_agent_string = GRPC_ARG_PRIMARY_USER_AGENT_STRING secondary_user_agent_string = GRPC_ARG_SECONDARY_USER_AGENT_STRING + ssl_session_cache = GRPC_SSL_SESSION_CACHE_ARG ssl_target_name_override = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi index 4588db30d3..52cfccb677 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi @@ -23,6 +23,7 @@ cdef class Server: cdef bint is_shutdown # notification of complete shutdown received # used at dealloc when user forgets to shutdown cdef CompletionQueue backup_shutdown_queue + # TODO(https://github.com/grpc/grpc/issues/15662): Elide this. cdef list references cdef list registered_completion_queues diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index 707ec742dd..da3dd21244 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -18,6 +18,8 @@ import logging import time import grpc +_LOGGER = logging.getLogger(__name__) + cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper( void* user_data, grpc_ssl_server_certificate_config **config) with gil: # This is a credentials.ServerCertificateConfig @@ -34,13 +36,13 @@ cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapp try: cert_config_wrapper = user_cb() except Exception: - logging.exception('Error fetching certificate config') + _LOGGER.exception('Error fetching certificate config') return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL if cert_config_wrapper is None: return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED elif not isinstance( cert_config_wrapper, grpc.ServerCertificateConfiguration): - logging.error( + _LOGGER.error( 'Error fetching certificate configuration: certificate ' 'configuration must be of type grpc.ServerCertificateConfiguration, ' 'not %s' % type(cert_config_wrapper).__name__) diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd index c8ace7c3cc..e33c01c28f 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pxd +++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd @@ -29,4 +29,4 @@ include "_cygrpc/server.pxd.pxi" include "_cygrpc/tag.pxd.pxi" include "_cygrpc/time.pxd.pxi" -include "_cygrpc/grpc_gevent.pxd" +include "_cygrpc/grpc_gevent.pxd.pxi" diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index f5f08fc983..fb16fb16bf 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -36,7 +36,7 @@ include "_cygrpc/server.pyx.pxi" include "_cygrpc/tag.pyx.pxi" include "_cygrpc/time.pyx.pxi" -include "_cygrpc/grpc_gevent.pyx" +include "_cygrpc/grpc_gevent.pyx.pxi" # # initialize gRPC diff --git a/src/python/grpcio/grpc/_interceptor.py b/src/python/grpcio/grpc/_interceptor.py index f465e35a9c..6b7a912a94 100644 --- a/src/python/grpcio/grpc/_interceptor.py +++ b/src/python/grpcio/grpc/_interceptor.py @@ -100,6 +100,12 @@ class _LocalFailure(grpc.RpcError, grpc.Future, grpc.Call): def cancelled(self): return False + def is_active(self): + return False + + def time_remaining(self): + return None + def running(self): return False @@ -115,6 +121,9 @@ class _LocalFailure(grpc.RpcError, grpc.Future, grpc.Call): def traceback(self, ignored_timeout=None): return self._traceback + def add_callback(self, callback): + return False + def add_done_callback(self, fn): fn(self) @@ -288,11 +297,11 @@ class _Channel(grpc.Channel): self._channel = channel self._interceptor = interceptor - def subscribe(self, *args, **kwargs): - self._channel.subscribe(*args, **kwargs) + def subscribe(self, callback, try_to_connect=False): + self._channel.subscribe(callback, try_to_connect=try_to_connect) - def unsubscribe(self, *args, **kwargs): - self._channel.unsubscribe(*args, **kwargs) + def unsubscribe(self, callback): + self._channel.unsubscribe(callback) def unary_unary(self, method, diff --git a/src/python/grpcio/grpc/_plugin_wrapping.py b/src/python/grpcio/grpc/_plugin_wrapping.py index 6785e5876a..916ee080b6 100644 --- a/src/python/grpcio/grpc/_plugin_wrapping.py +++ b/src/python/grpcio/grpc/_plugin_wrapping.py @@ -20,6 +20,8 @@ import grpc from grpc import _common from grpc._cython import cygrpc +_LOGGER = logging.getLogger(__name__) + class _AuthMetadataContext( collections.namedtuple('AuthMetadataContext', ( @@ -76,7 +78,7 @@ class _Plugin(object): _AuthMetadataPluginCallback( callback_state, callback)) except Exception as exception: # pylint: disable=broad-except - logging.exception( + _LOGGER.exception( 'AuthMetadataPluginCallback "%s" raised exception!', self._metadata_plugin) with callback_state.lock: diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index d849cadbee..7276a7fd90 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -27,6 +27,8 @@ from grpc import _interceptor from grpc._cython import cygrpc from grpc.framework.foundation import callable_util +_LOGGER = logging.getLogger(__name__) + _SHUTDOWN_TAG = 'shutdown' _REQUEST_CALL_TAG = 'request_call' @@ -279,7 +281,7 @@ class _Context(grpc.ServicerContext): def abort(self, code, details): # treat OK like other invalid arguments: fail the RPC if code == grpc.StatusCode.OK: - logging.error( + _LOGGER.error( 'abort() called with StatusCode.OK; returning UNKNOWN') code = grpc.StatusCode.UNKNOWN details = '' @@ -328,6 +330,8 @@ class _RequestIterator(object): self._state.request = None return request + raise AssertionError() # should never run + def _next(self): with self._state.condition: self._raise_or_start_receive_message() @@ -390,7 +394,7 @@ def _call_behavior(rpc_event, state, behavior, argument, request_deserializer): b'RPC Aborted') elif exception not in state.rpc_errors: details = 'Exception calling application: {}'.format(exception) - logging.exception(details) + _LOGGER.exception(details) _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, _common.encode(details)) return None, False @@ -408,7 +412,7 @@ def _take_response_from_response_iterator(rpc_event, state, response_iterator): b'RPC Aborted') elif exception not in state.rpc_errors: details = 'Exception iterating responses: {}'.format(exception) - logging.exception(details) + _LOGGER.exception(details) _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, _common.encode(details)) return None, False @@ -617,7 +621,7 @@ def _handle_call(rpc_event, generic_handlers, interceptor_pipeline, thread_pool, interceptor_pipeline) except Exception as exception: # pylint: disable=broad-except details = 'Exception servicing handler: {}'.format(exception) - logging.exception(details) + _LOGGER.exception(details) return _reject_rpc(rpc_event, cygrpc.StatusCode.unknown, b'Error in service handler!'), None if method_handler is None: @@ -785,7 +789,16 @@ def _start(state): thread.start() -class Server(grpc.Server): +def _validate_generic_rpc_handlers(generic_rpc_handlers): + for generic_rpc_handler in generic_rpc_handlers: + service_attribute = getattr(generic_rpc_handler, 'service', None) + if service_attribute is None: + raise AttributeError( + '"{}" must conform to grpc.GenericRpcHandler type but does ' + 'not have "service" method!'.format(generic_rpc_handler)) + + +class _Server(grpc.Server): # pylint: disable=too-many-arguments def __init__(self, thread_pool, generic_handlers, interceptors, options, @@ -798,6 +811,7 @@ class Server(grpc.Server): thread_pool, maximum_concurrent_rpcs) def add_generic_rpc_handlers(self, generic_rpc_handlers): + _validate_generic_rpc_handlers(generic_rpc_handlers) _add_generic_handlers(self._state, generic_rpc_handlers) def add_insecure_port(self, address): @@ -815,3 +829,10 @@ class Server(grpc.Server): def __del__(self): _stop(self._state, None) + + +def create_server(thread_pool, generic_rpc_handlers, interceptors, options, + maximum_concurrent_rpcs): + _validate_generic_rpc_handlers(generic_rpc_handlers) + return _Server(thread_pool, generic_rpc_handlers, interceptors, options, + maximum_concurrent_rpcs) diff --git a/src/python/grpcio/grpc/_utilities.py b/src/python/grpcio/grpc/_utilities.py index 25bd1ceae2..d90b34bcbd 100644 --- a/src/python/grpcio/grpc/_utilities.py +++ b/src/python/grpcio/grpc/_utilities.py @@ -116,6 +116,8 @@ class _ChannelReadyFuture(grpc.Future): callable_util.call_logging_exceptions( done_callback, _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE, self) + return True + def cancelled(self): with self._condition: return self._cancelled diff --git a/src/python/grpcio/grpc/beta/_server_adaptations.py b/src/python/grpcio/grpc/beta/_server_adaptations.py index ccafec8951..80ac65b649 100644 --- a/src/python/grpcio/grpc/beta/_server_adaptations.py +++ b/src/python/grpcio/grpc/beta/_server_adaptations.py @@ -305,6 +305,7 @@ def _simple_method_handler(implementation, request_deserializer, response_serializer, None, None, None, _adapt_stream_stream_event( implementation.stream_stream_event)) + raise ValueError() def _flatten_method_pair_map(method_pair_map): diff --git a/src/python/grpcio/grpc/beta/utilities.py b/src/python/grpcio/grpc/beta/utilities.py index b5d8aac71a..fe3ce606c9 100644 --- a/src/python/grpcio/grpc/beta/utilities.py +++ b/src/python/grpcio/grpc/beta/utilities.py @@ -85,6 +85,8 @@ class _ChannelReadyFuture(future.Future): callable_util.call_logging_exceptions( done_callback, _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE, self) + return True + def cancelled(self): with self._condition: return self._cancelled diff --git a/src/python/grpcio/grpc/experimental/session_cache.py b/src/python/grpcio/grpc/experimental/session_cache.py new file mode 100644 index 0000000000..5c55f7c327 --- /dev/null +++ b/src/python/grpcio/grpc/experimental/session_cache.py @@ -0,0 +1,45 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""gRPC's APIs for TLS Session Resumption support""" + +from grpc._cython import cygrpc as _cygrpc + + +def ssl_session_cache_lru(capacity): + """Creates an SSLSessionCache with LRU replacement policy + + Args: + capacity: Size of the cache + + Returns: + An SSLSessionCache with LRU replacement policy that can be passed as a value for + the grpc.ssl_session_cache option to a grpc.Channel. SSL session caches are used + to store session tickets, which clients can present to resume previous TLS sessions + with a server. + """ + return SSLSessionCache(_cygrpc.SSLSessionCacheLRU(capacity)) + + +class SSLSessionCache(object): + """An encapsulation of a session cache used for TLS session resumption. + + Instances of this class can be passed to a Channel as values for the + grpc.ssl_session_cache option + """ + + def __init__(self, cache): + self._cache = cache + + def __int__(self): + return int(self._cache) diff --git a/src/python/grpcio/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py index b9b9c49f17..24daf3406f 100644 --- a/src/python/grpcio/grpc/framework/foundation/callable_util.py +++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py @@ -21,6 +21,8 @@ import logging import six +_LOGGER = logging.getLogger(__name__) + class Outcome(six.with_metaclass(abc.ABCMeta)): """A sum type describing the outcome of some call. @@ -53,7 +55,7 @@ def _call_logging_exceptions(behavior, message, *args, **kwargs): return _EasyOutcome(Outcome.Kind.RETURNED, behavior(*args, **kwargs), None) except Exception as e: # pylint: disable=broad-except - logging.exception(message) + _LOGGER.exception(message) return _EasyOutcome(Outcome.Kind.RAISED, None, e) diff --git a/src/python/grpcio/grpc/framework/foundation/logging_pool.py b/src/python/grpcio/grpc/framework/foundation/logging_pool.py index f75df10042..216e3990db 100644 --- a/src/python/grpcio/grpc/framework/foundation/logging_pool.py +++ b/src/python/grpcio/grpc/framework/foundation/logging_pool.py @@ -17,6 +17,8 @@ import logging from concurrent import futures +_LOGGER = logging.getLogger(__name__) + def _wrap(behavior): """Wraps an arbitrary callable behavior in exception-logging.""" @@ -25,7 +27,7 @@ def _wrap(behavior): try: return behavior(*args, **kwargs) except Exception: - logging.exception( + _LOGGER.exception( 'Unexpected exception from %s executed in logging pool!', behavior) raise diff --git a/src/python/grpcio/grpc/framework/foundation/stream_util.py b/src/python/grpcio/grpc/framework/foundation/stream_util.py index 04631d9899..1faaf29bd7 100644 --- a/src/python/grpcio/grpc/framework/foundation/stream_util.py +++ b/src/python/grpcio/grpc/framework/foundation/stream_util.py @@ -19,6 +19,7 @@ import threading from grpc.framework.foundation import stream _NO_VALUE = object() +_LOGGER = logging.getLogger(__name__) class TransformingConsumer(stream.Consumer): @@ -46,10 +47,10 @@ class IterableConsumer(stream.Consumer): self._values = [] self._active = True - def consume(self, stock_reply): + def consume(self, value): with self._condition: if self._active: - self._values.append(stock_reply) + self._values.append(value) self._condition.notify() def terminate(self): @@ -57,10 +58,10 @@ class IterableConsumer(stream.Consumer): self._active = False self._condition.notify() - def consume_and_terminate(self, stock_reply): + def consume_and_terminate(self, value): with self._condition: if self._active: - self._values.append(stock_reply) + self._values.append(value) self._active = False self._condition.notify() @@ -103,7 +104,7 @@ class ThreadSwitchingConsumer(stream.Consumer): else: sink.consume(value) except Exception as e: # pylint:disable=broad-except - logging.exception(e) + _LOGGER.exception(e) with self._lock: if terminate: diff --git a/src/python/grpcio_testing/grpc_testing/__init__.py b/src/python/grpcio_testing/grpc_testing/__init__.py index e87d0ffc96..65fdd1b8ca 100644 --- a/src/python/grpcio_testing/grpc_testing/__init__.py +++ b/src/python/grpcio_testing/grpc_testing/__init__.py @@ -14,9 +14,9 @@ """Objects for use in testing gRPC Python-using application code.""" import abc +import six from google.protobuf import descriptor -import six import grpc diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py b/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py index ebce652eeb..191b1c1726 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py @@ -18,6 +18,7 @@ import threading import grpc _NOT_YET_OBSERVED = object() +_LOGGER = logging.getLogger(__name__) def _cancel(handler): @@ -248,7 +249,7 @@ def consume_requests(request_iterator, handler): break except Exception: # pylint: disable=broad-except details = 'Exception iterating requests!' - logging.exception(details) + _LOGGER.exception(details) handler.cancel(grpc.StatusCode.UNKNOWN, details) consumption = threading.Thread(target=_consume) diff --git a/src/python/grpcio_testing/grpc_testing/_server/_handler.py b/src/python/grpcio_testing/grpc_testing/_server/_handler.py index d4f50f6863..0e3404b0d0 100644 --- a/src/python/grpcio_testing/grpc_testing/_server/_handler.py +++ b/src/python/grpcio_testing/grpc_testing/_server/_handler.py @@ -105,10 +105,10 @@ class _Handler(Handler): self._expiration_future.cancel() self._condition.notify_all() - def add_termination_callback(self, termination_callback): + def add_termination_callback(self, callback): with self._condition: if self._code is None: - self._termination_callbacks.append(termination_callback) + self._termination_callbacks.append(callback) return True else: return False diff --git a/src/python/grpcio_testing/grpc_testing/_server/_rpc.py b/src/python/grpcio_testing/grpc_testing/_server/_rpc.py index 2060e8daff..b856da100f 100644 --- a/src/python/grpcio_testing/grpc_testing/_server/_rpc.py +++ b/src/python/grpcio_testing/grpc_testing/_server/_rpc.py @@ -18,6 +18,8 @@ import threading import grpc from grpc_testing import _common +_LOGGER = logging.getLogger(__name__) + class Rpc(object): @@ -47,7 +49,7 @@ class Rpc(object): try: callback() except Exception: # pylint: disable=broad-except - logging.exception('Exception calling server-side callback!') + _LOGGER.exception('Exception calling server-side callback!') callback_calling_thread = threading.Thread(target=call_back) callback_calling_thread.start() @@ -86,7 +88,7 @@ class Rpc(object): def application_exception_abort(self, exception): with self._condition: if exception not in self._rpc_errors: - logging.exception('Exception calling application!') + _LOGGER.exception('Exception calling application!') self._abort( grpc.StatusCode.UNKNOWN, 'Exception calling application: {}'.format(exception)) diff --git a/src/python/grpcio_testing/grpc_testing/_time.py b/src/python/grpcio_testing/grpc_testing/_time.py index afbdad3524..75e6db3458 100644 --- a/src/python/grpcio_testing/grpc_testing/_time.py +++ b/src/python/grpcio_testing/grpc_testing/_time.py @@ -21,13 +21,15 @@ import time as _time import grpc import grpc_testing +_LOGGER = logging.getLogger(__name__) + def _call(behaviors): for behavior in behaviors: try: behavior() except Exception: # pylint: disable=broad-except - logging.exception('Exception calling behavior "%r"!', behavior) + _LOGGER.exception('Exception calling behavior "%r"!', behavior) def _call_in_thread(behaviors): diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 42e01c18d3..a23c980017 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -119,6 +119,8 @@ class TestGevent(setuptools.Command): # I have no idea why this doesn't work in gevent, but it shouldn't even be # using the c-core 'testing._client_test.ClientTest.test_infinite_request_stream_real_time', + # TODO(https://github.com/grpc/grpc/issues/15743) enable this test + 'unit._session_cache_test.SSLSessionCacheTest.testSSLSessionCacheLRU', # TODO(https://github.com/grpc/grpc/issues/14789) enable this test 'unit._server_ssl_cert_config_test', # TODO(https://github.com/grpc/grpc/issues/14901) enable this test diff --git a/src/python/grpcio_tests/tests/_loader.py b/src/python/grpcio_tests/tests/_loader.py index be0af64646..80c107aa8e 100644 --- a/src/python/grpcio_tests/tests/_loader.py +++ b/src/python/grpcio_tests/tests/_loader.py @@ -48,12 +48,13 @@ class Loader(object): # measure unnecessarily suffers) coverage_context = coverage.Coverage(data_suffix=True) coverage_context.start() - modules = [importlib.import_module(name) for name in names] - for module in modules: - self.visit_module(module) - for module in modules: + imported_modules = tuple( + importlib.import_module(name) for name in names) + for imported_module in imported_modules: + self.visit_module(imported_module) + for imported_module in imported_modules: try: - package_paths = module.__path__ + package_paths = imported_module.__path__ except AttributeError: continue self.walk_packages(package_paths) diff --git a/src/python/grpcio_tests/tests/_result.py b/src/python/grpcio_tests/tests/_result.py index b105f18e78..e5378b7ea3 100644 --- a/src/python/grpcio_tests/tests/_result.py +++ b/src/python/grpcio_tests/tests/_result.py @@ -144,10 +144,6 @@ class AugmentedResult(unittest.TestResult): super(AugmentedResult, self).startTestRun() self.cases = dict() - def stopTestRun(self): - """See unittest.TestResult.stopTestRun.""" - super(AugmentedResult, self).stopTestRun() - def startTest(self, test): """See unittest.TestResult.startTest.""" super(AugmentedResult, self).startTest(test) @@ -155,19 +151,19 @@ class AugmentedResult(unittest.TestResult): self.cases[case_id] = CaseResult( id=case_id, name=test.id(), kind=CaseResult.Kind.RUNNING) - def addError(self, test, error): + def addError(self, test, err): """See unittest.TestResult.addError.""" - super(AugmentedResult, self).addError(test, error) + super(AugmentedResult, self).addError(test, err) case_id = self.id_map(test) self.cases[case_id] = self.cases[case_id].updated( - kind=CaseResult.Kind.ERROR, traceback=error) + kind=CaseResult.Kind.ERROR, traceback=err) - def addFailure(self, test, error): + def addFailure(self, test, err): """See unittest.TestResult.addFailure.""" - super(AugmentedResult, self).addFailure(test, error) + super(AugmentedResult, self).addFailure(test, err) case_id = self.id_map(test) self.cases[case_id] = self.cases[case_id].updated( - kind=CaseResult.Kind.FAILURE, traceback=error) + kind=CaseResult.Kind.FAILURE, traceback=err) def addSuccess(self, test): """See unittest.TestResult.addSuccess.""" @@ -183,12 +179,12 @@ class AugmentedResult(unittest.TestResult): self.cases[case_id] = self.cases[case_id].updated( kind=CaseResult.Kind.SKIP, skip_reason=reason) - def addExpectedFailure(self, test, error): + def addExpectedFailure(self, test, err): """See unittest.TestResult.addExpectedFailure.""" - super(AugmentedResult, self).addExpectedFailure(test, error) + super(AugmentedResult, self).addExpectedFailure(test, err) case_id = self.id_map(test) self.cases[case_id] = self.cases[case_id].updated( - kind=CaseResult.Kind.EXPECTED_FAILURE, traceback=error) + kind=CaseResult.Kind.EXPECTED_FAILURE, traceback=err) def addUnexpectedSuccess(self, test): """See unittest.TestResult.addUnexpectedSuccess.""" @@ -249,13 +245,6 @@ class CoverageResult(AugmentedResult): self.coverage_context.save() self.coverage_context = None - def stopTestRun(self): - """See unittest.TestResult.stopTestRun.""" - super(CoverageResult, self).stopTestRun() - # TODO(atash): Dig deeper into why the following line fails to properly - # combine coverage data from the Cython plugin. - #coverage.Coverage().combine() - class _Colors(object): """Namespaced constants for terminal color magic numbers.""" @@ -295,16 +284,16 @@ class TerminalResult(CoverageResult): self.out.write(summary(self)) self.out.flush() - def addError(self, test, error): + def addError(self, test, err): """See unittest.TestResult.addError.""" - super(TerminalResult, self).addError(test, error) + super(TerminalResult, self).addError(test, err) self.out.write( _Colors.FAIL + 'ERROR {}\n'.format(test.id()) + _Colors.END) self.out.flush() - def addFailure(self, test, error): + def addFailure(self, test, err): """See unittest.TestResult.addFailure.""" - super(TerminalResult, self).addFailure(test, error) + super(TerminalResult, self).addFailure(test, err) self.out.write( _Colors.FAIL + 'FAILURE {}\n'.format(test.id()) + _Colors.END) self.out.flush() @@ -323,9 +312,9 @@ class TerminalResult(CoverageResult): _Colors.INFO + 'SKIP {}\n'.format(test.id()) + _Colors.END) self.out.flush() - def addExpectedFailure(self, test, error): + def addExpectedFailure(self, test, err): """See unittest.TestResult.addExpectedFailure.""" - super(TerminalResult, self).addExpectedFailure(test, error) + super(TerminalResult, self).addExpectedFailure(test, err) self.out.write( _Colors.INFO + 'FAILURE_OK {}\n'.format(test.id()) + _Colors.END) self.out.flush() diff --git a/src/python/grpcio_tests/tests/interop/methods.py b/src/python/grpcio_tests/tests/interop/methods.py index b728ffd704..cda15a68a3 100644 --- a/src/python/grpcio_tests/tests/interop/methods.py +++ b/src/python/grpcio_tests/tests/interop/methods.py @@ -144,8 +144,8 @@ def _large_unary_common_behavior(stub, fill_username, fill_oauth_scope, def _empty_unary(stub): response = stub.EmptyCall(empty_pb2.Empty()) if not isinstance(response, empty_pb2.Empty): - raise TypeError('response is of type "%s", not empty_pb2.Empty!', - type(response)) + raise TypeError( + 'response is of type "%s", not empty_pb2.Empty!' % type(response)) def _large_unary(stub): diff --git a/src/python/grpcio_tests/tests/interop/server.py b/src/python/grpcio_tests/tests/interop/server.py index 0810de2394..fd28d498a1 100644 --- a/src/python/grpcio_tests/tests/interop/server.py +++ b/src/python/grpcio_tests/tests/interop/server.py @@ -26,6 +26,7 @@ from tests.interop import resources from tests.unit import test_common _ONE_DAY_IN_SECONDS = 60 * 60 * 24 +_LOGGER = logging.getLogger(__name__) def serve(): @@ -52,14 +53,14 @@ def serve(): server.add_insecure_port('[::]:{}'.format(args.port)) server.start() - logging.info('Server serving.') + _LOGGER.info('Server serving.') try: while True: time.sleep(_ONE_DAY_IN_SECONDS) except BaseException as e: - logging.info('Caught exception "%s"; stopping server...', e) + _LOGGER.info('Caught exception "%s"; stopping server...', e) server.stop(None) - logging.info('Server stopped; exiting.') + _LOGGER.info('Server stopped; exiting.') if __name__ == '__main__': diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 0d94426413..ebc41c63f0 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -53,6 +53,8 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestCertConfigReuse", "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithClientAuth", "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", + "unit._server_test.ServerTest", + "unit._session_cache_test.SSLSessionCacheTest", "unit.beta._beta_features_test.BetaFeaturesTest", "unit.beta._beta_features_test.ContextManagementAndLifecycleTest", "unit.beta._connectivity_channel_test.ConnectivityStatesTest", diff --git a/src/python/grpcio_tests/tests/unit/_auth_context_test.py b/src/python/grpcio_tests/tests/unit/_auth_context_test.py index 8c1a30e032..d174051070 100644 --- a/src/python/grpcio_tests/tests/unit/_auth_context_test.py +++ b/src/python/grpcio_tests/tests/unit/_auth_context_test.py @@ -18,6 +18,7 @@ import unittest import grpc from grpc import _channel +from grpc.experimental import session_cache import six from tests.unit import test_common @@ -140,6 +141,50 @@ class AuthContextTest(unittest.TestCase): self.assertSequenceEqual([b'*.test.google.com'], auth_ctx['x509_common_name']) + def _do_one_shot_client_rpc(self, channel_creds, channel_options, port, + expect_ssl_session_reused): + channel = grpc.secure_channel( + 'localhost:{}'.format(port), channel_creds, options=channel_options) + response = channel.unary_unary(_UNARY_UNARY)(_REQUEST) + auth_data = pickle.loads(response) + self.assertEqual(expect_ssl_session_reused, + auth_data[_AUTH_CTX]['ssl_session_reused']) + channel.close() + + def testSessionResumption(self): + # Set up a secure server + handler = grpc.method_handlers_generic_handler('test', { + 'UnaryUnary': + grpc.unary_unary_rpc_method_handler(handle_unary_unary) + }) + server = test_common.test_server() + server.add_generic_rpc_handlers((handler,)) + server_cred = grpc.ssl_server_credentials(_SERVER_CERTS) + port = server.add_secure_port('[::]:0', server_cred) + server.start() + + # Create a cache for TLS session tickets + cache = session_cache.ssl_session_cache_lru(1) + channel_creds = grpc.ssl_channel_credentials( + root_certificates=_TEST_ROOT_CERTIFICATES) + channel_options = _PROPERTY_OPTIONS + ( + ('grpc.ssl_session_cache', cache),) + + # Initial connection has no session to resume + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port, + expect_ssl_session_reused=[b'false']) + + # Subsequent connections resume sessions + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port, + expect_ssl_session_reused=[b'true']) + server.stop(None) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests/unit/_junkdrawer/stock_pb2.py b/src/python/grpcio_tests/tests/unit/_junkdrawer/stock_pb2.py deleted file mode 100644 index 2bf1e1cc0d..0000000000 --- a/src/python/grpcio_tests/tests/unit/_junkdrawer/stock_pb2.py +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# TODO(nathaniel): Remove this from source control after having made -# generation from the stock.proto source part of GRPC's build-and-test -# process. - -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: stock.proto - -import sys -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode('latin1')) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database -from google.protobuf import descriptor_pb2 -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - -DESCRIPTOR = _descriptor.FileDescriptor( - name='stock.proto', - package='stock', - serialized_pb=_b( - '\n\x0bstock.proto\x12\x05stock\">\n\x0cStockRequest\x12\x0e\n\x06symbol\x18\x01 \x01(\t\x12\x1e\n\x13num_trades_to_watch\x18\x02 \x01(\x05:\x01\x30\"+\n\nStockReply\x12\r\n\x05price\x18\x01 \x01(\x02\x12\x0e\n\x06symbol\x18\x02 \x01(\t2\x96\x02\n\x05Stock\x12=\n\x11GetLastTradePrice\x12\x13.stock.StockRequest\x1a\x11.stock.StockReply\"\x00\x12I\n\x19GetLastTradePriceMultiple\x12\x13.stock.StockRequest\x1a\x11.stock.StockReply\"\x00(\x01\x30\x01\x12?\n\x11WatchFutureTrades\x12\x13.stock.StockRequest\x1a\x11.stock.StockReply\"\x00\x30\x01\x12\x42\n\x14GetHighestTradePrice\x12\x13.stock.StockRequest\x1a\x11.stock.StockReply\"\x00(\x01' - )) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -_STOCKREQUEST = _descriptor.Descriptor( - name='StockRequest', - full_name='stock.StockRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='symbol', - full_name='stock.StockRequest.symbol', - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='num_trades_to_watch', - full_name='stock.StockRequest.num_trades_to_watch', - index=1, - number=2, - type=5, - cpp_type=1, - label=1, - has_default_value=True, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - options=None), - ], - extensions=[], - nested_types=[], - enum_types=[], - options=None, - is_extendable=False, - extension_ranges=[], - oneofs=[], - serialized_start=22, - serialized_end=84,) - -_STOCKREPLY = _descriptor.Descriptor( - name='StockReply', - full_name='stock.StockReply', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='price', - full_name='stock.StockReply.price', - index=0, - number=1, - type=2, - cpp_type=6, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='symbol', - full_name='stock.StockReply.symbol', - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - options=None), - ], - extensions=[], - nested_types=[], - enum_types=[], - options=None, - is_extendable=False, - extension_ranges=[], - oneofs=[], - serialized_start=86, - serialized_end=129,) - -DESCRIPTOR.message_types_by_name['StockRequest'] = _STOCKREQUEST -DESCRIPTOR.message_types_by_name['StockReply'] = _STOCKREPLY - -StockRequest = _reflection.GeneratedProtocolMessageType( - 'StockRequest', - (_message.Message,), - dict( - DESCRIPTOR=_STOCKREQUEST, - __module__='stock_pb2' - # @@protoc_insertion_point(class_scope:stock.StockRequest) - )) -_sym_db.RegisterMessage(StockRequest) - -StockReply = _reflection.GeneratedProtocolMessageType( - 'StockReply', - (_message.Message,), - dict( - DESCRIPTOR=_STOCKREPLY, - __module__='stock_pb2' - # @@protoc_insertion_point(class_scope:stock.StockReply) - )) -_sym_db.RegisterMessage(StockReply) - -# @@protoc_insertion_point(module_scope) diff --git a/src/python/grpcio_tests/tests/unit/_server_test.py b/src/python/grpcio_tests/tests/unit/_server_test.py new file mode 100644 index 0000000000..acf4a17921 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_server_test.py @@ -0,0 +1,52 @@ +# Copyright 2018 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from concurrent import futures +import unittest + +import grpc + + +class _ActualGenericRpcHandler(grpc.GenericRpcHandler): + + def service(self, handler_call_details): + return None + + +class ServerTest(unittest.TestCase): + + def test_not_a_generic_rpc_handler_at_construction(self): + with self.assertRaises(AttributeError) as exception_context: + grpc.server( + futures.ThreadPoolExecutor(max_workers=5), + handlers=[ + _ActualGenericRpcHandler(), + object(), + ]) + self.assertIn('grpc.GenericRpcHandler', + str(exception_context.exception)) + + def test_not_a_generic_rpc_handler_after_construction(self): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=5)) + with self.assertRaises(AttributeError) as exception_context: + server.add_generic_rpc_handlers([ + _ActualGenericRpcHandler(), + object(), + ]) + self.assertIn('grpc.GenericRpcHandler', + str(exception_context.exception)) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests/unit/_session_cache_test.py b/src/python/grpcio_tests/tests/unit/_session_cache_test.py new file mode 100644 index 0000000000..b4e4670fa7 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_session_cache_test.py @@ -0,0 +1,145 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Tests experimental TLS Session Resumption API""" + +import pickle +import unittest + +import grpc +from grpc import _channel +from grpc.experimental import session_cache + +from tests.unit import test_common +from tests.unit import resources + +_REQUEST = b'\x00\x00\x00' +_RESPONSE = b'\x00\x00\x00' + +_UNARY_UNARY = '/test/UnaryUnary' + +_SERVER_HOST_OVERRIDE = 'foo.test.google.fr' +_ID = 'id' +_ID_KEY = 'id_key' +_AUTH_CTX = 'auth_ctx' + +_PRIVATE_KEY = resources.private_key() +_CERTIFICATE_CHAIN = resources.certificate_chain() +_TEST_ROOT_CERTIFICATES = resources.test_root_certificates() +_SERVER_CERTS = ((_PRIVATE_KEY, _CERTIFICATE_CHAIN),) +_PROPERTY_OPTIONS = (( + 'grpc.ssl_target_name_override', + _SERVER_HOST_OVERRIDE, +),) + + +def handle_unary_unary(request, servicer_context): + return pickle.dumps({ + _ID: servicer_context.peer_identities(), + _ID_KEY: servicer_context.peer_identity_key(), + _AUTH_CTX: servicer_context.auth_context() + }) + + +def start_secure_server(): + handler = grpc.method_handlers_generic_handler('test', { + 'UnaryUnary': + grpc.unary_unary_rpc_method_handler(handle_unary_unary) + }) + server = test_common.test_server() + server.add_generic_rpc_handlers((handler,)) + server_cred = grpc.ssl_server_credentials(_SERVER_CERTS) + port = server.add_secure_port('[::]:0', server_cred) + server.start() + + return server, port + + +class SSLSessionCacheTest(unittest.TestCase): + + def _do_one_shot_client_rpc(self, channel_creds, channel_options, port, + expect_ssl_session_reused): + channel = grpc.secure_channel( + 'localhost:{}'.format(port), channel_creds, options=channel_options) + response = channel.unary_unary(_UNARY_UNARY)(_REQUEST) + auth_data = pickle.loads(response) + self.assertEqual(expect_ssl_session_reused, + auth_data[_AUTH_CTX]['ssl_session_reused']) + channel.close() + + def testSSLSessionCacheLRU(self): + server_1, port_1 = start_secure_server() + + cache = session_cache.ssl_session_cache_lru(1) + channel_creds = grpc.ssl_channel_credentials( + root_certificates=_TEST_ROOT_CERTIFICATES) + channel_options = _PROPERTY_OPTIONS + ( + ('grpc.ssl_session_cache', cache),) + + # Initial connection has no session to resume + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_1, + expect_ssl_session_reused=[b'false']) + + # Connection to server_1 resumes from initial session + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_1, + expect_ssl_session_reused=[b'true']) + + # Connection to a different server with the same name overwrites the cache entry + server_2, port_2 = start_secure_server() + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_2, + expect_ssl_session_reused=[b'false']) + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_2, + expect_ssl_session_reused=[b'true']) + server_2.stop(None) + + # Connection to server_1 now falls back to full TLS handshake + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_1, + expect_ssl_session_reused=[b'false']) + + # Re-creating server_1 causes old sessions to become invalid + server_1.stop(None) + server_1, port_1 = start_secure_server() + + # Old sessions should no longer be valid + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_1, + expect_ssl_session_reused=[b'false']) + + # Resumption should work for subsequent connections + self._do_one_shot_client_rpc( + channel_creds, + channel_options, + port_1, + expect_ssl_session_reused=[b'true']) + server_1.stop(None) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 06adb33739..435217bacd 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -35,7 +35,7 @@ def get_deps(target_dict): deps = [] - if target_dict.get('baselib', False): + if target_dict.get('baselib', False) or target_dict['name'] == 'address_sorting': deps.append("${_gRPC_BASELIB_LIBRARIES}") if target_dict.get('build', None) in ['protoc']: deps.append("${_gRPC_PROTOBUF_PROTOC_LIBRARIES}") diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index af97d81834..a767a612a6 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -68,6 +68,14 @@ excl = grpc_private_files(libs) return [file for file in out if not file in excl] + def cfstream_private_headers(libs): + out = grpc_lib_files(libs, ("grpc_cfstream",), ("own_headers",)) + return out + + def cfstream_private_files(libs): + out = grpc_lib_files(libs, ("grpc_cfstream",), ("own_src", "own_headers")) + return out + def ruby_multiline_list(files, indent): return (',\n' + indent*' ').join('\'%s\'' % f for f in files) %> @@ -175,6 +183,16 @@ ss.private_header_files = ${ruby_multiline_list(grpc_private_headers(libs), 30)} end + s.subspec 'CFStream-Implementation' do |ss| + ss.header_mappings_dir = '.' + ss.dependency "#{s.name}/Implementation", version + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + ss.source_files = ${ruby_multiline_list(cfstream_private_files(filegroups), 22)} + ss.private_header_files = ${ruby_multiline_list(cfstream_private_headers(filegroups), 30)} + end + s.subspec 'Cronet-Interface' do |ss| ss.header_mappings_dir = 'include/grpc' ss.source_files = ${ruby_multiline_list(grpc_cronet_public_headers(libs), 22)} diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index d2dcc429ef..96966784f1 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -43,12 +43,25 @@ s.header_dir = name src_dir = 'src/objective-c/ProtoRPC' - s.source_files = "#{src_dir}/*.{h,m}" - s.header_mappings_dir = "#{src_dir}" - s.dependency 'gRPC', version - s.dependency 'gRPC-RxLibrary', version - s.dependency 'Protobuf', '~> 3.0' + s.default_subspec = 'Main' + + s.subspec 'Main' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.dependency 'gRPC', version + ss.dependency 'gRPC-RxLibrary', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "#{src_dir}/*.{h,m}" + end + s.subspec 'CFStream' do |ss| + ss.dependency 'gRPC/CFStream', version + ss.dependency "#{s.name}/Main", version + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + end + s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 6616e74bd7..a3190c2d8e 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -65,6 +65,16 @@ ss.dependency 'gRPC-Core', version end + # This subspec is mutually exclusive with the `Main` subspec + s.subspec 'CFStream' do |ss| + ss.dependency 'gRPC-Core/CFStream-Implementation', version + ss.dependency "#{s.name}/Main", version + + ss.pod_target_xcconfig = { + 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' + } + end + s.subspec 'GID' do |ss| ss.ios.deployment_target = '7.0' diff --git a/templates/src/csharp/build_packages_dotnetcli.bat.template b/templates/src/csharp/build_packages_dotnetcli.bat.template index 1bf78c4d23..45010fec74 100755 --- a/templates/src/csharp/build_packages_dotnetcli.bat.template +++ b/templates/src/csharp/build_packages_dotnetcli.bat.template @@ -49,6 +49,7 @@ %%DOTNET% pack --configuration Release Grpc.Reflection --output ..\..\..\artifacts || goto :error %%NUGET% pack Grpc.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts || goto :error + %%NUGET% pack Grpc.Core.NativeDebug.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts %%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts @rem copy resulting nuget packages to artifacts directory diff --git a/templates/src/csharp/build_packages_dotnetcli.sh.template b/templates/src/csharp/build_packages_dotnetcli.sh.template index ddfea74744..1172582ebd 100755 --- a/templates/src/csharp/build_packages_dotnetcli.sh.template +++ b/templates/src/csharp/build_packages_dotnetcli.sh.template @@ -48,6 +48,7 @@ dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts nuget pack Grpc.nuspec -Version "${settings.csharp_version}" -OutputDirectory ../../artifacts + nuget pack Grpc.Core.NativeDebug.nuspec -Version "${settings.csharp_version}" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "${settings.csharp_version}" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc index ecebe833b3..01002fec72 100644 --- a/test/core/avl/avl_test.cc +++ b/test/core/avl/avl_test.cc @@ -241,3365 +241,6 @@ static void test_badcase1(void) { grpc_avl_unref(avl, nullptr); } -static void test_badcase2(void) { - grpc_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase2"); - - avl = grpc_avl_create(&int_int_vtable); - avl = grpc_avl_add(avl, box(288), box(1), nullptr); - avl = remove_int(avl, 415); - avl = grpc_avl_add(avl, box(953), box(3), nullptr); - avl = grpc_avl_add(avl, box(101), box(4), nullptr); - avl = grpc_avl_add(avl, box(516), box(5), nullptr); - avl = grpc_avl_add(avl, box(547), box(6), nullptr); - avl = grpc_avl_add(avl, box(467), box(7), nullptr); - avl = grpc_avl_add(avl, box(793), box(8), nullptr); - avl = remove_int(avl, 190); - avl = grpc_avl_add(avl, box(687), box(10), nullptr); - avl = grpc_avl_add(avl, box(242), box(11), nullptr); - avl = grpc_avl_add(avl, box(142), box(12), nullptr); - avl = remove_int(avl, 705); - avl = remove_int(avl, 578); - avl = remove_int(avl, 767); - avl = remove_int(avl, 183); - avl = grpc_avl_add(avl, box(950), box(17), nullptr); - avl = grpc_avl_add(avl, box(622), box(18), nullptr); - avl = remove_int(avl, 513); - avl = remove_int(avl, 429); - avl = grpc_avl_add(avl, box(205), box(21), nullptr); - avl = remove_int(avl, 663); - avl = remove_int(avl, 953); - avl = remove_int(avl, 892); - avl = grpc_avl_add(avl, box(236), box(25), nullptr); - avl = remove_int(avl, 982); - avl = remove_int(avl, 201); - avl = remove_int(avl, 684); - avl = grpc_avl_add(avl, box(572), box(29), nullptr); - avl = remove_int(avl, 817); - avl = grpc_avl_add(avl, box(970), box(31), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 574); - avl = grpc_avl_add(avl, box(752), box(34), nullptr); - avl = grpc_avl_add(avl, box(670), box(35), nullptr); - avl = grpc_avl_add(avl, box(69), box(36), nullptr); - avl = remove_int(avl, 111); - avl = remove_int(avl, 523); - avl = grpc_avl_add(avl, box(141), box(39), nullptr); - avl = remove_int(avl, 159); - avl = grpc_avl_add(avl, box(947), box(41), nullptr); - avl = grpc_avl_add(avl, box(855), box(42), nullptr); - avl = remove_int(avl, 218); - avl = remove_int(avl, 6); - avl = grpc_avl_add(avl, box(753), box(45), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 799); - avl = grpc_avl_add(avl, box(572), box(48), nullptr); - avl = remove_int(avl, 376); - avl = remove_int(avl, 413); - avl = grpc_avl_add(avl, box(458), box(51), nullptr); - avl = remove_int(avl, 897); - avl = grpc_avl_add(avl, box(191), box(53), nullptr); - avl = grpc_avl_add(avl, box(609), box(54), nullptr); - avl = remove_int(avl, 787); - avl = remove_int(avl, 710); - avl = remove_int(avl, 886); - avl = remove_int(avl, 835); - avl = remove_int(avl, 33); - avl = grpc_avl_add(avl, box(871), box(60), nullptr); - avl = remove_int(avl, 641); - avl = grpc_avl_add(avl, box(462), box(62), nullptr); - avl = remove_int(avl, 359); - avl = remove_int(avl, 767); - avl = grpc_avl_add(avl, box(310), box(65), nullptr); - avl = remove_int(avl, 757); - avl = remove_int(avl, 639); - avl = remove_int(avl, 314); - avl = grpc_avl_add(avl, box(2), box(69), nullptr); - avl = remove_int(avl, 138); - avl = grpc_avl_add(avl, box(669), box(71), nullptr); - avl = remove_int(avl, 477); - avl = grpc_avl_add(avl, box(366), box(73), nullptr); - avl = grpc_avl_add(avl, box(612), box(74), nullptr); - avl = grpc_avl_add(avl, box(106), box(75), nullptr); - avl = remove_int(avl, 161); - avl = grpc_avl_add(avl, box(388), box(77), nullptr); - avl = grpc_avl_add(avl, box(141), box(78), nullptr); - avl = remove_int(avl, 633); - avl = remove_int(avl, 459); - avl = grpc_avl_add(avl, box(40), box(81), nullptr); - avl = remove_int(avl, 689); - avl = grpc_avl_add(avl, box(823), box(83), nullptr); - avl = remove_int(avl, 485); - avl = grpc_avl_add(avl, box(903), box(85), nullptr); - avl = grpc_avl_add(avl, box(592), box(86), nullptr); - avl = remove_int(avl, 448); - avl = grpc_avl_add(avl, box(56), box(88), nullptr); - avl = remove_int(avl, 333); - avl = grpc_avl_add(avl, box(189), box(90), nullptr); - avl = grpc_avl_add(avl, box(103), box(91), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 974); - avl = grpc_avl_add(avl, box(215), box(94), nullptr); - avl = remove_int(avl, 189); - avl = remove_int(avl, 504); - avl = grpc_avl_add(avl, box(868), box(97), nullptr); - avl = remove_int(avl, 909); - avl = remove_int(avl, 148); - avl = remove_int(avl, 469); - avl = grpc_avl_add(avl, box(994), box(101), nullptr); - avl = grpc_avl_add(avl, box(576), box(102), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 209); - avl = grpc_avl_add(avl, box(276), box(105), nullptr); - avl = remove_int(avl, 856); - avl = grpc_avl_add(avl, box(750), box(107), nullptr); - avl = remove_int(avl, 871); - avl = grpc_avl_add(avl, box(301), box(109), nullptr); - avl = remove_int(avl, 260); - avl = remove_int(avl, 737); - avl = remove_int(avl, 719); - avl = grpc_avl_add(avl, box(933), box(113), nullptr); - avl = grpc_avl_add(avl, box(225), box(114), nullptr); - avl = grpc_avl_add(avl, box(975), box(115), nullptr); - avl = grpc_avl_add(avl, box(86), box(116), nullptr); - avl = remove_int(avl, 732); - avl = grpc_avl_add(avl, box(340), box(118), nullptr); - avl = grpc_avl_add(avl, box(271), box(119), nullptr); - avl = remove_int(avl, 206); - avl = grpc_avl_add(avl, box(949), box(121), nullptr); - avl = grpc_avl_add(avl, box(927), box(122), nullptr); - avl = grpc_avl_add(avl, box(34), box(123), nullptr); - avl = grpc_avl_add(avl, box(351), box(124), nullptr); - avl = remove_int(avl, 836); - avl = grpc_avl_add(avl, box(825), box(126), nullptr); - avl = grpc_avl_add(avl, box(352), box(127), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 101); - avl = grpc_avl_add(avl, box(320), box(130), nullptr); - avl = grpc_avl_add(avl, box(3), box(131), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 44); - avl = grpc_avl_add(avl, box(525), box(134), nullptr); - avl = grpc_avl_add(avl, box(864), box(135), nullptr); - avl = grpc_avl_add(avl, box(863), box(136), nullptr); - avl = remove_int(avl, 770); - avl = grpc_avl_add(avl, box(440), box(138), nullptr); - avl = remove_int(avl, 516); - avl = grpc_avl_add(avl, box(116), box(140), nullptr); - avl = remove_int(avl, 380); - avl = grpc_avl_add(avl, box(878), box(142), nullptr); - avl = remove_int(avl, 439); - avl = grpc_avl_add(avl, box(994), box(144), nullptr); - avl = remove_int(avl, 294); - avl = remove_int(avl, 593); - avl = grpc_avl_add(avl, box(696), box(147), nullptr); - avl = remove_int(avl, 8); - avl = grpc_avl_add(avl, box(881), box(149), nullptr); - avl = remove_int(avl, 32); - avl = remove_int(avl, 242); - avl = grpc_avl_add(avl, box(487), box(152), nullptr); - avl = grpc_avl_add(avl, box(637), box(153), nullptr); - avl = grpc_avl_add(avl, box(793), box(154), nullptr); - avl = grpc_avl_add(avl, box(696), box(155), nullptr); - avl = remove_int(avl, 458); - avl = grpc_avl_add(avl, box(828), box(157), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 274); - avl = grpc_avl_add(avl, box(783), box(160), nullptr); - avl = remove_int(avl, 21); - avl = grpc_avl_add(avl, box(866), box(162), nullptr); - avl = remove_int(avl, 919); - avl = grpc_avl_add(avl, box(435), box(164), nullptr); - avl = remove_int(avl, 385); - avl = grpc_avl_add(avl, box(475), box(166), nullptr); - avl = remove_int(avl, 339); - avl = grpc_avl_add(avl, box(615), box(168), nullptr); - avl = remove_int(avl, 866); - avl = remove_int(avl, 82); - avl = remove_int(avl, 271); - avl = grpc_avl_add(avl, box(590), box(172), nullptr); - avl = grpc_avl_add(avl, box(852), box(173), nullptr); - avl = remove_int(avl, 318); - avl = remove_int(avl, 82); - avl = grpc_avl_add(avl, box(672), box(176), nullptr); - avl = remove_int(avl, 430); - avl = grpc_avl_add(avl, box(821), box(178), nullptr); - avl = grpc_avl_add(avl, box(365), box(179), nullptr); - avl = remove_int(avl, 78); - avl = grpc_avl_add(avl, box(700), box(181), nullptr); - avl = grpc_avl_add(avl, box(353), box(182), nullptr); - avl = remove_int(avl, 492); - avl = grpc_avl_add(avl, box(991), box(184), nullptr); - avl = remove_int(avl, 330); - avl = grpc_avl_add(avl, box(873), box(186), nullptr); - avl = remove_int(avl, 589); - avl = grpc_avl_add(avl, box(676), box(188), nullptr); - avl = grpc_avl_add(avl, box(790), box(189), nullptr); - avl = remove_int(avl, 521); - avl = remove_int(avl, 47); - avl = grpc_avl_add(avl, box(976), box(192), nullptr); - avl = grpc_avl_add(avl, box(683), box(193), nullptr); - avl = remove_int(avl, 803); - avl = remove_int(avl, 1006); - avl = grpc_avl_add(avl, box(775), box(196), nullptr); - avl = grpc_avl_add(avl, box(411), box(197), nullptr); - avl = grpc_avl_add(avl, box(697), box(198), nullptr); - avl = remove_int(avl, 50); - avl = grpc_avl_add(avl, box(213), box(200), nullptr); - avl = remove_int(avl, 714); - avl = grpc_avl_add(avl, box(981), box(202), nullptr); - avl = grpc_avl_add(avl, box(502), box(203), nullptr); - avl = grpc_avl_add(avl, box(697), box(204), nullptr); - avl = grpc_avl_add(avl, box(603), box(205), nullptr); - avl = grpc_avl_add(avl, box(117), box(206), nullptr); - avl = remove_int(avl, 363); - avl = grpc_avl_add(avl, box(104), box(208), nullptr); - avl = remove_int(avl, 842); - avl = grpc_avl_add(avl, box(48), box(210), nullptr); - avl = remove_int(avl, 764); - avl = grpc_avl_add(avl, box(482), box(212), nullptr); - avl = grpc_avl_add(avl, box(928), box(213), nullptr); - avl = grpc_avl_add(avl, box(30), box(214), nullptr); - avl = grpc_avl_add(avl, box(820), box(215), nullptr); - avl = grpc_avl_add(avl, box(334), box(216), nullptr); - avl = remove_int(avl, 306); - avl = grpc_avl_add(avl, box(789), box(218), nullptr); - avl = remove_int(avl, 924); - avl = grpc_avl_add(avl, box(53), box(220), nullptr); - avl = remove_int(avl, 657); - avl = grpc_avl_add(avl, box(130), box(222), nullptr); - avl = grpc_avl_add(avl, box(239), box(223), nullptr); - avl = remove_int(avl, 20); - avl = grpc_avl_add(avl, box(117), box(225), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 891); - avl = grpc_avl_add(avl, box(9), box(228), nullptr); - avl = grpc_avl_add(avl, box(496), box(229), nullptr); - avl = grpc_avl_add(avl, box(750), box(230), nullptr); - avl = grpc_avl_add(avl, box(283), box(231), nullptr); - avl = grpc_avl_add(avl, box(802), box(232), nullptr); - avl = remove_int(avl, 352); - avl = grpc_avl_add(avl, box(374), box(234), nullptr); - avl = grpc_avl_add(avl, box(6), box(235), nullptr); - avl = grpc_avl_add(avl, box(756), box(236), nullptr); - avl = grpc_avl_add(avl, box(597), box(237), nullptr); - avl = grpc_avl_add(avl, box(661), box(238), nullptr); - avl = remove_int(avl, 96); - avl = grpc_avl_add(avl, box(894), box(240), nullptr); - avl = remove_int(avl, 749); - avl = grpc_avl_add(avl, box(71), box(242), nullptr); - avl = remove_int(avl, 68); - avl = grpc_avl_add(avl, box(388), box(244), nullptr); - avl = remove_int(avl, 119); - avl = remove_int(avl, 856); - avl = grpc_avl_add(avl, box(176), box(247), nullptr); - avl = grpc_avl_add(avl, box(993), box(248), nullptr); - avl = remove_int(avl, 178); - avl = remove_int(avl, 781); - avl = remove_int(avl, 771); - avl = remove_int(avl, 848); - avl = remove_int(avl, 376); - avl = remove_int(avl, 157); - avl = remove_int(avl, 142); - avl = remove_int(avl, 686); - avl = grpc_avl_add(avl, box(779), box(257), nullptr); - avl = grpc_avl_add(avl, box(484), box(258), nullptr); - avl = remove_int(avl, 837); - avl = grpc_avl_add(avl, box(388), box(260), nullptr); - avl = remove_int(avl, 987); - avl = grpc_avl_add(avl, box(336), box(262), nullptr); - avl = remove_int(avl, 855); - avl = grpc_avl_add(avl, box(668), box(264), nullptr); - avl = remove_int(avl, 648); - avl = grpc_avl_add(avl, box(193), box(266), nullptr); - avl = remove_int(avl, 939); - avl = grpc_avl_add(avl, box(740), box(268), nullptr); - avl = grpc_avl_add(avl, box(503), box(269), nullptr); - avl = grpc_avl_add(avl, box(765), box(270), nullptr); - avl = remove_int(avl, 924); - avl = remove_int(avl, 513); - avl = grpc_avl_add(avl, box(161), box(273), nullptr); - avl = grpc_avl_add(avl, box(502), box(274), nullptr); - avl = grpc_avl_add(avl, box(846), box(275), nullptr); - avl = remove_int(avl, 931); - avl = grpc_avl_add(avl, box(87), box(277), nullptr); - avl = grpc_avl_add(avl, box(949), box(278), nullptr); - avl = grpc_avl_add(avl, box(548), box(279), nullptr); - avl = grpc_avl_add(avl, box(951), box(280), nullptr); - avl = remove_int(avl, 1018); - avl = remove_int(avl, 568); - avl = grpc_avl_add(avl, box(138), box(283), nullptr); - avl = grpc_avl_add(avl, box(202), box(284), nullptr); - avl = grpc_avl_add(avl, box(157), box(285), nullptr); - avl = grpc_avl_add(avl, box(264), box(286), nullptr); - avl = grpc_avl_add(avl, box(370), box(287), nullptr); - avl = remove_int(avl, 736); - avl = remove_int(avl, 751); - avl = remove_int(avl, 506); - avl = remove_int(avl, 81); - avl = remove_int(avl, 358); - avl = remove_int(avl, 657); - avl = remove_int(avl, 86); - avl = grpc_avl_add(avl, box(876), box(295), nullptr); - avl = remove_int(avl, 354); - avl = grpc_avl_add(avl, box(134), box(297), nullptr); - avl = remove_int(avl, 781); - avl = remove_int(avl, 183); - avl = grpc_avl_add(avl, box(914), box(300), nullptr); - avl = remove_int(avl, 926); - avl = remove_int(avl, 398); - avl = remove_int(avl, 932); - avl = remove_int(avl, 804); - avl = remove_int(avl, 326); - avl = grpc_avl_add(avl, box(208), box(306), nullptr); - avl = grpc_avl_add(avl, box(699), box(307), nullptr); - avl = remove_int(avl, 576); - avl = remove_int(avl, 850); - avl = remove_int(avl, 514); - avl = remove_int(avl, 676); - avl = remove_int(avl, 549); - avl = remove_int(avl, 767); - avl = grpc_avl_add(avl, box(58), box(314), nullptr); - avl = grpc_avl_add(avl, box(265), box(315), nullptr); - avl = grpc_avl_add(avl, box(268), box(316), nullptr); - avl = grpc_avl_add(avl, box(103), box(317), nullptr); - avl = grpc_avl_add(avl, box(440), box(318), nullptr); - avl = remove_int(avl, 777); - avl = grpc_avl_add(avl, box(670), box(320), nullptr); - avl = remove_int(avl, 506); - avl = remove_int(avl, 487); - avl = grpc_avl_add(avl, box(421), box(323), nullptr); - avl = remove_int(avl, 514); - avl = grpc_avl_add(avl, box(701), box(325), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 872); - avl = remove_int(avl, 139); - avl = grpc_avl_add(avl, box(781), box(329), nullptr); - avl = grpc_avl_add(avl, box(543), box(330), nullptr); - avl = grpc_avl_add(avl, box(147), box(331), nullptr); - avl = remove_int(avl, 190); - avl = grpc_avl_add(avl, box(453), box(333), nullptr); - avl = remove_int(avl, 262); - avl = remove_int(avl, 850); - avl = remove_int(avl, 286); - avl = remove_int(avl, 787); - avl = grpc_avl_add(avl, box(514), box(338), nullptr); - avl = remove_int(avl, 812); - avl = grpc_avl_add(avl, box(431), box(340), nullptr); - avl = grpc_avl_add(avl, box(8), box(341), nullptr); - avl = remove_int(avl, 843); - avl = grpc_avl_add(avl, box(831), box(343), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 157); - avl = grpc_avl_add(avl, box(612), box(346), nullptr); - avl = grpc_avl_add(avl, box(802), box(347), nullptr); - avl = remove_int(avl, 554); - avl = grpc_avl_add(avl, box(409), box(349), nullptr); - avl = grpc_avl_add(avl, box(439), box(350), nullptr); - avl = grpc_avl_add(avl, box(725), box(351), nullptr); - avl = grpc_avl_add(avl, box(568), box(352), nullptr); - avl = remove_int(avl, 475); - avl = remove_int(avl, 672); - avl = remove_int(avl, 62); - avl = remove_int(avl, 753); - avl = grpc_avl_add(avl, box(435), box(357), nullptr); - avl = grpc_avl_add(avl, box(950), box(358), nullptr); - avl = grpc_avl_add(avl, box(532), box(359), nullptr); - avl = grpc_avl_add(avl, box(832), box(360), nullptr); - avl = remove_int(avl, 390); - avl = grpc_avl_add(avl, box(993), box(362), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 401); - avl = grpc_avl_add(avl, box(316), box(365), nullptr); - avl = remove_int(avl, 843); - avl = grpc_avl_add(avl, box(541), box(367), nullptr); - avl = grpc_avl_add(avl, box(505), box(368), nullptr); - avl = remove_int(avl, 445); - avl = remove_int(avl, 256); - avl = grpc_avl_add(avl, box(232), box(371), nullptr); - avl = remove_int(avl, 577); - avl = remove_int(avl, 558); - avl = grpc_avl_add(avl, box(910), box(374), nullptr); - avl = remove_int(avl, 902); - avl = remove_int(avl, 755); - avl = remove_int(avl, 114); - avl = remove_int(avl, 438); - avl = remove_int(avl, 224); - avl = grpc_avl_add(avl, box(920), box(380), nullptr); - avl = grpc_avl_add(avl, box(655), box(381), nullptr); - avl = remove_int(avl, 557); - avl = remove_int(avl, 102); - avl = remove_int(avl, 165); - avl = grpc_avl_add(avl, box(191), box(385), nullptr); - avl = remove_int(avl, 30); - avl = grpc_avl_add(avl, box(406), box(387), nullptr); - avl = grpc_avl_add(avl, box(66), box(388), nullptr); - avl = grpc_avl_add(avl, box(87), box(389), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 671); - avl = grpc_avl_add(avl, box(234), box(392), nullptr); - avl = remove_int(avl, 463); - avl = grpc_avl_add(avl, box(75), box(394), nullptr); - avl = grpc_avl_add(avl, box(487), box(395), nullptr); - avl = remove_int(avl, 203); - avl = grpc_avl_add(avl, box(711), box(397), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 798); - avl = remove_int(avl, 337); - avl = grpc_avl_add(avl, box(877), box(401), nullptr); - avl = grpc_avl_add(avl, box(388), box(402), nullptr); - avl = remove_int(avl, 975); - avl = grpc_avl_add(avl, box(200), box(404), nullptr); - avl = grpc_avl_add(avl, box(408), box(405), nullptr); - avl = grpc_avl_add(avl, box(3), box(406), nullptr); - avl = grpc_avl_add(avl, box(971), box(407), nullptr); - avl = remove_int(avl, 841); - avl = remove_int(avl, 910); - avl = remove_int(avl, 74); - avl = remove_int(avl, 888); - avl = grpc_avl_add(avl, box(492), box(412), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 364); - avl = grpc_avl_add(avl, box(215), box(415), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 45); - avl = grpc_avl_add(avl, box(328), box(418), nullptr); - avl = grpc_avl_add(avl, box(597), box(419), nullptr); - avl = remove_int(avl, 34); - avl = grpc_avl_add(avl, box(736), box(421), nullptr); - avl = remove_int(avl, 37); - avl = grpc_avl_add(avl, box(275), box(423), nullptr); - avl = grpc_avl_add(avl, box(70), box(424), nullptr); - avl = grpc_avl_add(avl, box(771), box(425), nullptr); - avl = remove_int(avl, 536); - avl = remove_int(avl, 421); - avl = grpc_avl_add(avl, box(186), box(428), nullptr); - avl = grpc_avl_add(avl, box(788), box(429), nullptr); - avl = grpc_avl_add(avl, box(224), box(430), nullptr); - avl = remove_int(avl, 228); - avl = grpc_avl_add(avl, box(48), box(432), nullptr); - avl = grpc_avl_add(avl, box(120), box(433), nullptr); - avl = grpc_avl_add(avl, box(269), box(434), nullptr); - avl = grpc_avl_add(avl, box(904), box(435), nullptr); - avl = remove_int(avl, 699); - avl = grpc_avl_add(avl, box(340), box(437), nullptr); - avl = remove_int(avl, 276); - avl = grpc_avl_add(avl, box(591), box(439), nullptr); - avl = grpc_avl_add(avl, box(778), box(440), nullptr); - avl = remove_int(avl, 490); - avl = remove_int(avl, 973); - avl = grpc_avl_add(avl, box(294), box(443), nullptr); - avl = grpc_avl_add(avl, box(323), box(444), nullptr); - avl = remove_int(avl, 685); - avl = grpc_avl_add(avl, box(38), box(446), nullptr); - avl = grpc_avl_add(avl, box(525), box(447), nullptr); - avl = remove_int(avl, 162); - avl = grpc_avl_add(avl, box(462), box(449), nullptr); - avl = grpc_avl_add(avl, box(340), box(450), nullptr); - avl = remove_int(avl, 734); - avl = remove_int(avl, 959); - avl = grpc_avl_add(avl, box(752), box(453), nullptr); - avl = grpc_avl_add(avl, box(667), box(454), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 657); - avl = grpc_avl_add(avl, box(711), box(457), nullptr); - avl = remove_int(avl, 937); - avl = grpc_avl_add(avl, box(741), box(459), nullptr); - avl = grpc_avl_add(avl, box(40), box(460), nullptr); - avl = remove_int(avl, 784); - avl = grpc_avl_add(avl, box(292), box(462), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 931); - avl = remove_int(avl, 886); - avl = grpc_avl_add(avl, box(968), box(466), nullptr); - avl = remove_int(avl, 263); - avl = grpc_avl_add(avl, box(647), box(468), nullptr); - avl = grpc_avl_add(avl, box(92), box(469), nullptr); - avl = remove_int(avl, 310); - avl = grpc_avl_add(avl, box(711), box(471), nullptr); - avl = grpc_avl_add(avl, box(675), box(472), nullptr); - avl = remove_int(avl, 549); - avl = grpc_avl_add(avl, box(380), box(474), nullptr); - avl = remove_int(avl, 825); - avl = grpc_avl_add(avl, box(668), box(476), nullptr); - avl = remove_int(avl, 498); - avl = grpc_avl_add(avl, box(870), box(478), nullptr); - avl = grpc_avl_add(avl, box(391), box(479), nullptr); - avl = grpc_avl_add(avl, box(264), box(480), nullptr); - avl = remove_int(avl, 1); - avl = remove_int(avl, 849); - avl = remove_int(avl, 88); - avl = remove_int(avl, 255); - avl = remove_int(avl, 763); - avl = remove_int(avl, 831); - avl = grpc_avl_add(avl, box(508), box(487), nullptr); - avl = remove_int(avl, 849); - avl = remove_int(avl, 47); - avl = grpc_avl_add(avl, box(299), box(490), nullptr); - avl = remove_int(avl, 625); - avl = remove_int(avl, 433); - avl = remove_int(avl, 904); - avl = remove_int(avl, 761); - avl = grpc_avl_add(avl, box(33), box(495), nullptr); - avl = grpc_avl_add(avl, box(524), box(496), nullptr); - avl = remove_int(avl, 210); - avl = remove_int(avl, 299); - avl = grpc_avl_add(avl, box(823), box(499), nullptr); - avl = remove_int(avl, 479); - avl = remove_int(avl, 96); - avl = remove_int(avl, 1013); - avl = grpc_avl_add(avl, box(768), box(503), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 20); - avl = grpc_avl_add(avl, box(663), box(506), nullptr); - avl = remove_int(avl, 882); - avl = grpc_avl_add(avl, box(745), box(508), nullptr); - avl = remove_int(avl, 352); - avl = grpc_avl_add(avl, box(10), box(510), nullptr); - avl = remove_int(avl, 484); - avl = grpc_avl_add(avl, box(420), box(512), nullptr); - avl = grpc_avl_add(avl, box(884), box(513), nullptr); - avl = grpc_avl_add(avl, box(993), box(514), nullptr); - avl = grpc_avl_add(avl, box(251), box(515), nullptr); - avl = remove_int(avl, 222); - avl = grpc_avl_add(avl, box(734), box(517), nullptr); - avl = grpc_avl_add(avl, box(952), box(518), nullptr); - avl = remove_int(avl, 26); - avl = remove_int(avl, 270); - avl = remove_int(avl, 481); - avl = remove_int(avl, 693); - avl = remove_int(avl, 1006); - avl = grpc_avl_add(avl, box(77), box(524), nullptr); - avl = remove_int(avl, 897); - avl = grpc_avl_add(avl, box(719), box(526), nullptr); - avl = grpc_avl_add(avl, box(622), box(527), nullptr); - avl = remove_int(avl, 28); - avl = remove_int(avl, 836); - avl = remove_int(avl, 142); - avl = grpc_avl_add(avl, box(445), box(531), nullptr); - avl = grpc_avl_add(avl, box(410), box(532), nullptr); - avl = remove_int(avl, 575); - avl = grpc_avl_add(avl, box(634), box(534), nullptr); - avl = grpc_avl_add(avl, box(906), box(535), nullptr); - avl = remove_int(avl, 649); - avl = grpc_avl_add(avl, box(813), box(537), nullptr); - avl = remove_int(avl, 702); - avl = remove_int(avl, 732); - avl = grpc_avl_add(avl, box(105), box(540), nullptr); - avl = grpc_avl_add(avl, box(867), box(541), nullptr); - avl = remove_int(avl, 964); - avl = remove_int(avl, 941); - avl = grpc_avl_add(avl, box(947), box(544), nullptr); - avl = remove_int(avl, 990); - avl = grpc_avl_add(avl, box(816), box(546), nullptr); - avl = remove_int(avl, 429); - avl = remove_int(avl, 567); - avl = remove_int(avl, 541); - avl = remove_int(avl, 583); - avl = grpc_avl_add(avl, box(57), box(551), nullptr); - avl = grpc_avl_add(avl, box(786), box(552), nullptr); - avl = grpc_avl_add(avl, box(526), box(553), nullptr); - avl = remove_int(avl, 642); - avl = remove_int(avl, 220); - avl = remove_int(avl, 840); - avl = remove_int(avl, 548); - avl = grpc_avl_add(avl, box(528), box(558), nullptr); - avl = grpc_avl_add(avl, box(749), box(559), nullptr); - avl = grpc_avl_add(avl, box(194), box(560), nullptr); - avl = remove_int(avl, 517); - avl = grpc_avl_add(avl, box(102), box(562), nullptr); - avl = remove_int(avl, 189); - avl = grpc_avl_add(avl, box(927), box(564), nullptr); - avl = remove_int(avl, 846); - avl = remove_int(avl, 130); - avl = grpc_avl_add(avl, box(694), box(567), nullptr); - avl = remove_int(avl, 750); - avl = grpc_avl_add(avl, box(357), box(569), nullptr); - avl = remove_int(avl, 431); - avl = remove_int(avl, 91); - avl = grpc_avl_add(avl, box(640), box(572), nullptr); - avl = remove_int(avl, 4); - avl = grpc_avl_add(avl, box(81), box(574), nullptr); - avl = grpc_avl_add(avl, box(595), box(575), nullptr); - avl = remove_int(avl, 444); - avl = remove_int(avl, 262); - avl = remove_int(avl, 11); - avl = grpc_avl_add(avl, box(192), box(579), nullptr); - avl = grpc_avl_add(avl, box(158), box(580), nullptr); - avl = remove_int(avl, 401); - avl = remove_int(avl, 918); - avl = grpc_avl_add(avl, box(180), box(583), nullptr); - avl = remove_int(avl, 268); - avl = grpc_avl_add(avl, box(1012), box(585), nullptr); - avl = grpc_avl_add(avl, box(90), box(586), nullptr); - avl = grpc_avl_add(avl, box(946), box(587), nullptr); - avl = remove_int(avl, 719); - avl = grpc_avl_add(avl, box(874), box(589), nullptr); - avl = grpc_avl_add(avl, box(679), box(590), nullptr); - avl = remove_int(avl, 53); - avl = remove_int(avl, 534); - avl = grpc_avl_add(avl, box(646), box(593), nullptr); - avl = grpc_avl_add(avl, box(767), box(594), nullptr); - avl = grpc_avl_add(avl, box(460), box(595), nullptr); - avl = grpc_avl_add(avl, box(852), box(596), nullptr); - avl = grpc_avl_add(avl, box(189), box(597), nullptr); - avl = remove_int(avl, 932); - avl = remove_int(avl, 366); - avl = remove_int(avl, 907); - avl = grpc_avl_add(avl, box(875), box(601), nullptr); - avl = grpc_avl_add(avl, box(434), box(602), nullptr); - avl = grpc_avl_add(avl, box(704), box(603), nullptr); - avl = grpc_avl_add(avl, box(724), box(604), nullptr); - avl = grpc_avl_add(avl, box(930), box(605), nullptr); - avl = grpc_avl_add(avl, box(1000), box(606), nullptr); - avl = remove_int(avl, 479); - avl = grpc_avl_add(avl, box(275), box(608), nullptr); - avl = remove_int(avl, 32); - avl = grpc_avl_add(avl, box(939), box(610), nullptr); - avl = remove_int(avl, 943); - avl = remove_int(avl, 329); - avl = grpc_avl_add(avl, box(490), box(613), nullptr); - avl = remove_int(avl, 477); - avl = remove_int(avl, 414); - avl = remove_int(avl, 187); - avl = remove_int(avl, 334); - avl = grpc_avl_add(avl, box(40), box(618), nullptr); - avl = remove_int(avl, 751); - avl = grpc_avl_add(avl, box(568), box(620), nullptr); - avl = grpc_avl_add(avl, box(120), box(621), nullptr); - avl = grpc_avl_add(avl, box(617), box(622), nullptr); - avl = grpc_avl_add(avl, box(32), box(623), nullptr); - avl = remove_int(avl, 701); - avl = grpc_avl_add(avl, box(910), box(625), nullptr); - avl = remove_int(avl, 557); - avl = remove_int(avl, 361); - avl = remove_int(avl, 937); - avl = remove_int(avl, 100); - avl = remove_int(avl, 684); - avl = grpc_avl_add(avl, box(751), box(631), nullptr); - avl = remove_int(avl, 781); - avl = remove_int(avl, 469); - avl = remove_int(avl, 75); - avl = remove_int(avl, 561); - avl = grpc_avl_add(avl, box(854), box(636), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 258); - avl = remove_int(avl, 315); - avl = remove_int(avl, 261); - avl = grpc_avl_add(avl, box(552), box(641), nullptr); - avl = grpc_avl_add(avl, box(6), box(642), nullptr); - avl = grpc_avl_add(avl, box(680), box(643), nullptr); - avl = remove_int(avl, 741); - avl = remove_int(avl, 309); - avl = remove_int(avl, 272); - avl = grpc_avl_add(avl, box(249), box(647), nullptr); - avl = remove_int(avl, 97); - avl = remove_int(avl, 850); - avl = grpc_avl_add(avl, box(915), box(650), nullptr); - avl = grpc_avl_add(avl, box(816), box(651), nullptr); - avl = grpc_avl_add(avl, box(45), box(652), nullptr); - avl = grpc_avl_add(avl, box(168), box(653), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 239); - avl = grpc_avl_add(avl, box(684), box(656), nullptr); - avl = grpc_avl_add(avl, box(208), box(657), nullptr); - avl = grpc_avl_add(avl, box(681), box(658), nullptr); - avl = grpc_avl_add(avl, box(609), box(659), nullptr); - avl = grpc_avl_add(avl, box(645), box(660), nullptr); - avl = remove_int(avl, 799); - avl = grpc_avl_add(avl, box(955), box(662), nullptr); - avl = grpc_avl_add(avl, box(946), box(663), nullptr); - avl = grpc_avl_add(avl, box(744), box(664), nullptr); - avl = grpc_avl_add(avl, box(201), box(665), nullptr); - avl = grpc_avl_add(avl, box(136), box(666), nullptr); - avl = remove_int(avl, 357); - avl = grpc_avl_add(avl, box(974), box(668), nullptr); - avl = remove_int(avl, 485); - avl = grpc_avl_add(avl, box(1009), box(670), nullptr); - avl = grpc_avl_add(avl, box(517), box(671), nullptr); - avl = remove_int(avl, 491); - avl = grpc_avl_add(avl, box(336), box(673), nullptr); - avl = grpc_avl_add(avl, box(589), box(674), nullptr); - avl = remove_int(avl, 546); - avl = remove_int(avl, 840); - avl = remove_int(avl, 104); - avl = remove_int(avl, 347); - avl = grpc_avl_add(avl, box(801), box(679), nullptr); - avl = remove_int(avl, 799); - avl = remove_int(avl, 702); - avl = remove_int(avl, 996); - avl = remove_int(avl, 93); - avl = grpc_avl_add(avl, box(561), box(684), nullptr); - avl = grpc_avl_add(avl, box(25), box(685), nullptr); - avl = remove_int(avl, 278); - avl = grpc_avl_add(avl, box(191), box(687), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 918); - avl = remove_int(avl, 449); - avl = grpc_avl_add(avl, box(19), box(691), nullptr); - avl = grpc_avl_add(avl, box(762), box(692), nullptr); - avl = grpc_avl_add(avl, box(13), box(693), nullptr); - avl = grpc_avl_add(avl, box(151), box(694), nullptr); - avl = grpc_avl_add(avl, box(152), box(695), nullptr); - avl = grpc_avl_add(avl, box(793), box(696), nullptr); - avl = remove_int(avl, 862); - avl = remove_int(avl, 890); - avl = grpc_avl_add(avl, box(687), box(699), nullptr); - avl = grpc_avl_add(avl, box(509), box(700), nullptr); - avl = grpc_avl_add(avl, box(973), box(701), nullptr); - avl = remove_int(avl, 230); - avl = grpc_avl_add(avl, box(532), box(703), nullptr); - avl = remove_int(avl, 668); - avl = grpc_avl_add(avl, box(281), box(705), nullptr); - avl = grpc_avl_add(avl, box(867), box(706), nullptr); - avl = grpc_avl_add(avl, box(359), box(707), nullptr); - avl = remove_int(avl, 425); - avl = grpc_avl_add(avl, box(691), box(709), nullptr); - avl = grpc_avl_add(avl, box(163), box(710), nullptr); - avl = grpc_avl_add(avl, box(502), box(711), nullptr); - avl = remove_int(avl, 674); - avl = grpc_avl_add(avl, box(697), box(713), nullptr); - avl = remove_int(avl, 271); - avl = grpc_avl_add(avl, box(968), box(715), nullptr); - avl = grpc_avl_add(avl, box(48), box(716), nullptr); - avl = remove_int(avl, 543); - avl = grpc_avl_add(avl, box(35), box(718), nullptr); - avl = grpc_avl_add(avl, box(751), box(719), nullptr); - avl = grpc_avl_add(avl, box(478), box(720), nullptr); - avl = remove_int(avl, 797); - avl = remove_int(avl, 309); - avl = grpc_avl_add(avl, box(927), box(723), nullptr); - avl = remove_int(avl, 504); - avl = grpc_avl_add(avl, box(286), box(725), nullptr); - avl = grpc_avl_add(avl, box(413), box(726), nullptr); - avl = grpc_avl_add(avl, box(599), box(727), nullptr); - avl = remove_int(avl, 105); - avl = remove_int(avl, 605); - avl = grpc_avl_add(avl, box(632), box(730), nullptr); - avl = grpc_avl_add(avl, box(133), box(731), nullptr); - avl = remove_int(avl, 443); - avl = grpc_avl_add(avl, box(958), box(733), nullptr); - avl = grpc_avl_add(avl, box(729), box(734), nullptr); - avl = remove_int(avl, 158); - avl = grpc_avl_add(avl, box(694), box(736), nullptr); - avl = grpc_avl_add(avl, box(505), box(737), nullptr); - avl = remove_int(avl, 63); - avl = remove_int(avl, 714); - avl = grpc_avl_add(avl, box(1002), box(740), nullptr); - avl = remove_int(avl, 211); - avl = grpc_avl_add(avl, box(765), box(742), nullptr); - avl = grpc_avl_add(avl, box(455), box(743), nullptr); - avl = remove_int(avl, 59); - avl = remove_int(avl, 224); - avl = grpc_avl_add(avl, box(586), box(746), nullptr); - avl = grpc_avl_add(avl, box(348), box(747), nullptr); - avl = remove_int(avl, 10); - avl = remove_int(avl, 484); - avl = grpc_avl_add(avl, box(968), box(750), nullptr); - avl = grpc_avl_add(avl, box(923), box(751), nullptr); - avl = remove_int(avl, 573); - avl = remove_int(avl, 617); - avl = grpc_avl_add(avl, box(812), box(754), nullptr); - avl = grpc_avl_add(avl, box(179), box(755), nullptr); - avl = remove_int(avl, 284); - avl = remove_int(avl, 157); - avl = remove_int(avl, 177); - avl = remove_int(avl, 896); - avl = grpc_avl_add(avl, box(649), box(760), nullptr); - avl = grpc_avl_add(avl, box(927), box(761), nullptr); - avl = grpc_avl_add(avl, box(454), box(762), nullptr); - avl = grpc_avl_add(avl, box(217), box(763), nullptr); - avl = remove_int(avl, 534); - avl = grpc_avl_add(avl, box(180), box(765), nullptr); - avl = grpc_avl_add(avl, box(319), box(766), nullptr); - avl = remove_int(avl, 92); - avl = grpc_avl_add(avl, box(483), box(768), nullptr); - avl = remove_int(avl, 504); - avl = remove_int(avl, 1017); - avl = remove_int(avl, 37); - avl = remove_int(avl, 50); - avl = grpc_avl_add(avl, box(302), box(773), nullptr); - avl = remove_int(avl, 807); - avl = grpc_avl_add(avl, box(463), box(775), nullptr); - avl = grpc_avl_add(avl, box(271), box(776), nullptr); - avl = grpc_avl_add(avl, box(644), box(777), nullptr); - avl = remove_int(avl, 618); - avl = grpc_avl_add(avl, box(166), box(779), nullptr); - avl = grpc_avl_add(avl, box(538), box(780), nullptr); - avl = remove_int(avl, 606); - avl = grpc_avl_add(avl, box(425), box(782), nullptr); - avl = remove_int(avl, 725); - avl = remove_int(avl, 383); - avl = grpc_avl_add(avl, box(155), box(785), nullptr); - avl = remove_int(avl, 889); - avl = grpc_avl_add(avl, box(653), box(787), nullptr); - avl = remove_int(avl, 386); - avl = grpc_avl_add(avl, box(142), box(789), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 603); - avl = remove_int(avl, 971); - avl = grpc_avl_add(avl, box(80), box(793), nullptr); - avl = grpc_avl_add(avl, box(61), box(794), nullptr); - avl = grpc_avl_add(avl, box(693), box(795), nullptr); - avl = grpc_avl_add(avl, box(592), box(796), nullptr); - avl = grpc_avl_add(avl, box(433), box(797), nullptr); - avl = grpc_avl_add(avl, box(973), box(798), nullptr); - avl = remove_int(avl, 901); - avl = remove_int(avl, 340); - avl = remove_int(avl, 709); - avl = grpc_avl_add(avl, box(224), box(802), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 271); - avl = grpc_avl_add(avl, box(780), box(805), nullptr); - avl = grpc_avl_add(avl, box(867), box(806), nullptr); - avl = grpc_avl_add(avl, box(756), box(807), nullptr); - avl = grpc_avl_add(avl, box(583), box(808), nullptr); - avl = grpc_avl_add(avl, box(356), box(809), nullptr); - avl = grpc_avl_add(avl, box(58), box(810), nullptr); - avl = remove_int(avl, 219); - avl = grpc_avl_add(avl, box(301), box(812), nullptr); - avl = remove_int(avl, 643); - avl = remove_int(avl, 787); - avl = remove_int(avl, 583); - avl = remove_int(avl, 552); - avl = remove_int(avl, 308); - avl = remove_int(avl, 608); - avl = remove_int(avl, 363); - avl = remove_int(avl, 690); - avl = grpc_avl_add(avl, box(233), box(821), nullptr); - avl = grpc_avl_add(avl, box(479), box(822), nullptr); - avl = grpc_avl_add(avl, box(323), box(823), nullptr); - avl = grpc_avl_add(avl, box(802), box(824), nullptr); - avl = remove_int(avl, 682); - avl = remove_int(avl, 705); - avl = remove_int(avl, 487); - avl = grpc_avl_add(avl, box(530), box(828), nullptr); - avl = grpc_avl_add(avl, box(232), box(829), nullptr); - avl = remove_int(avl, 627); - avl = grpc_avl_add(avl, box(396), box(831), nullptr); - avl = grpc_avl_add(avl, box(61), box(832), nullptr); - avl = grpc_avl_add(avl, box(932), box(833), nullptr); - avl = grpc_avl_add(avl, box(108), box(834), nullptr); - avl = grpc_avl_add(avl, box(524), box(835), nullptr); - avl = remove_int(avl, 390); - avl = remove_int(avl, 307); - avl = grpc_avl_add(avl, box(722), box(838), nullptr); - avl = grpc_avl_add(avl, box(907), box(839), nullptr); - avl = remove_int(avl, 286); - avl = remove_int(avl, 337); - avl = remove_int(avl, 443); - avl = grpc_avl_add(avl, box(973), box(843), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 242); - avl = grpc_avl_add(avl, box(997), box(846), nullptr); - avl = grpc_avl_add(avl, box(689), box(847), nullptr); - avl = remove_int(avl, 318); - avl = grpc_avl_add(avl, box(703), box(849), nullptr); - avl = grpc_avl_add(avl, box(868), box(850), nullptr); - avl = grpc_avl_add(avl, box(200), box(851), nullptr); - avl = grpc_avl_add(avl, box(960), box(852), nullptr); - avl = grpc_avl_add(avl, box(80), box(853), nullptr); - avl = remove_int(avl, 113); - avl = grpc_avl_add(avl, box(135), box(855), nullptr); - avl = remove_int(avl, 529); - avl = grpc_avl_add(avl, box(366), box(857), nullptr); - avl = remove_int(avl, 272); - avl = grpc_avl_add(avl, box(921), box(859), nullptr); - avl = remove_int(avl, 497); - avl = grpc_avl_add(avl, box(712), box(861), nullptr); - avl = remove_int(avl, 777); - avl = remove_int(avl, 505); - avl = remove_int(avl, 974); - avl = remove_int(avl, 497); - avl = grpc_avl_add(avl, box(388), box(866), nullptr); - avl = grpc_avl_add(avl, box(29), box(867), nullptr); - avl = grpc_avl_add(avl, box(180), box(868), nullptr); - avl = grpc_avl_add(avl, box(983), box(869), nullptr); - avl = grpc_avl_add(avl, box(72), box(870), nullptr); - avl = grpc_avl_add(avl, box(693), box(871), nullptr); - avl = grpc_avl_add(avl, box(567), box(872), nullptr); - avl = remove_int(avl, 549); - avl = remove_int(avl, 351); - avl = grpc_avl_add(avl, box(1019), box(875), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 294); - avl = remove_int(avl, 61); - avl = grpc_avl_add(avl, box(409), box(879), nullptr); - avl = grpc_avl_add(avl, box(984), box(880), nullptr); - avl = grpc_avl_add(avl, box(830), box(881), nullptr); - avl = remove_int(avl, 579); - avl = grpc_avl_add(avl, box(672), box(883), nullptr); - avl = remove_int(avl, 968); - - grpc_avl_unref(avl, nullptr); -} - -static void test_badcase3(void) { - grpc_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase3"); - - avl = grpc_avl_create(&int_int_vtable); - avl = remove_int(avl, 624); - avl = grpc_avl_add(avl, box(59), box(2), nullptr); - avl = grpc_avl_add(avl, box(494), box(3), nullptr); - avl = grpc_avl_add(avl, box(226), box(4), nullptr); - avl = remove_int(avl, 524); - avl = grpc_avl_add(avl, box(540), box(6), nullptr); - avl = remove_int(avl, 1008); - avl = grpc_avl_add(avl, box(502), box(8), nullptr); - avl = remove_int(avl, 267); - avl = remove_int(avl, 764); - avl = remove_int(avl, 443); - avl = grpc_avl_add(avl, box(8), box(12), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 796); - avl = remove_int(avl, 1002); - avl = grpc_avl_add(avl, box(778), box(16), nullptr); - avl = remove_int(avl, 621); - avl = remove_int(avl, 891); - avl = remove_int(avl, 880); - avl = grpc_avl_add(avl, box(197), box(20), nullptr); - avl = grpc_avl_add(avl, box(441), box(21), nullptr); - avl = grpc_avl_add(avl, box(719), box(22), nullptr); - avl = remove_int(avl, 109); - avl = grpc_avl_add(avl, box(458), box(24), nullptr); - avl = remove_int(avl, 86); - avl = grpc_avl_add(avl, box(897), box(26), nullptr); - avl = grpc_avl_add(avl, box(997), box(27), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 425); - avl = remove_int(avl, 186); - avl = grpc_avl_add(avl, box(887), box(31), nullptr); - avl = grpc_avl_add(avl, box(1005), box(32), nullptr); - avl = grpc_avl_add(avl, box(778), box(33), nullptr); - avl = grpc_avl_add(avl, box(575), box(34), nullptr); - avl = remove_int(avl, 966); - avl = remove_int(avl, 1015); - avl = grpc_avl_add(avl, box(486), box(37), nullptr); - avl = grpc_avl_add(avl, box(809), box(38), nullptr); - avl = grpc_avl_add(avl, box(907), box(39), nullptr); - avl = grpc_avl_add(avl, box(971), box(40), nullptr); - avl = remove_int(avl, 441); - avl = remove_int(avl, 498); - avl = grpc_avl_add(avl, box(727), box(43), nullptr); - avl = remove_int(avl, 679); - avl = remove_int(avl, 740); - avl = remove_int(avl, 532); - avl = grpc_avl_add(avl, box(805), box(47), nullptr); - avl = remove_int(avl, 64); - avl = grpc_avl_add(avl, box(362), box(49), nullptr); - avl = grpc_avl_add(avl, box(170), box(50), nullptr); - avl = grpc_avl_add(avl, box(389), box(51), nullptr); - avl = grpc_avl_add(avl, box(689), box(52), nullptr); - avl = remove_int(avl, 871); - avl = grpc_avl_add(avl, box(447), box(54), nullptr); - avl = remove_int(avl, 718); - avl = grpc_avl_add(avl, box(724), box(56), nullptr); - avl = remove_int(avl, 215); - avl = grpc_avl_add(avl, box(550), box(58), nullptr); - avl = remove_int(avl, 932); - avl = grpc_avl_add(avl, box(47), box(60), nullptr); - avl = remove_int(avl, 46); - avl = remove_int(avl, 229); - avl = grpc_avl_add(avl, box(68), box(63), nullptr); - avl = grpc_avl_add(avl, box(387), box(64), nullptr); - avl = remove_int(avl, 933); - avl = remove_int(avl, 736); - avl = remove_int(avl, 719); - avl = grpc_avl_add(avl, box(150), box(68), nullptr); - avl = remove_int(avl, 875); - avl = remove_int(avl, 298); - avl = grpc_avl_add(avl, box(991), box(71), nullptr); - avl = remove_int(avl, 705); - avl = grpc_avl_add(avl, box(197), box(73), nullptr); - avl = grpc_avl_add(avl, box(101), box(74), nullptr); - avl = remove_int(avl, 436); - avl = grpc_avl_add(avl, box(755), box(76), nullptr); - avl = grpc_avl_add(avl, box(727), box(77), nullptr); - avl = remove_int(avl, 309); - avl = remove_int(avl, 253); - avl = grpc_avl_add(avl, box(203), box(80), nullptr); - avl = remove_int(avl, 231); - avl = grpc_avl_add(avl, box(461), box(82), nullptr); - avl = remove_int(avl, 316); - avl = remove_int(avl, 493); - avl = grpc_avl_add(avl, box(184), box(85), nullptr); - avl = remove_int(avl, 737); - avl = grpc_avl_add(avl, box(790), box(87), nullptr); - avl = grpc_avl_add(avl, box(335), box(88), nullptr); - avl = remove_int(avl, 649); - avl = grpc_avl_add(avl, box(69), box(90), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 543); - avl = grpc_avl_add(avl, box(784), box(93), nullptr); - avl = grpc_avl_add(avl, box(60), box(94), nullptr); - avl = grpc_avl_add(avl, box(525), box(95), nullptr); - avl = grpc_avl_add(avl, box(177), box(96), nullptr); - avl = grpc_avl_add(avl, box(178), box(97), nullptr); - avl = grpc_avl_add(avl, box(683), box(98), nullptr); - avl = grpc_avl_add(avl, box(226), box(99), nullptr); - avl = grpc_avl_add(avl, box(662), box(100), nullptr); - avl = remove_int(avl, 944); - avl = grpc_avl_add(avl, box(562), box(102), nullptr); - avl = grpc_avl_add(avl, box(793), box(103), nullptr); - avl = remove_int(avl, 673); - avl = grpc_avl_add(avl, box(310), box(105), nullptr); - avl = remove_int(avl, 479); - avl = remove_int(avl, 543); - avl = remove_int(avl, 159); - avl = remove_int(avl, 850); - avl = grpc_avl_add(avl, box(318), box(110), nullptr); - avl = grpc_avl_add(avl, box(483), box(111), nullptr); - avl = grpc_avl_add(avl, box(84), box(112), nullptr); - avl = remove_int(avl, 109); - avl = grpc_avl_add(avl, box(132), box(114), nullptr); - avl = grpc_avl_add(avl, box(920), box(115), nullptr); - avl = remove_int(avl, 746); - avl = grpc_avl_add(avl, box(145), box(117), nullptr); - avl = grpc_avl_add(avl, box(526), box(118), nullptr); - avl = remove_int(avl, 158); - avl = grpc_avl_add(avl, box(332), box(120), nullptr); - avl = grpc_avl_add(avl, box(918), box(121), nullptr); - avl = remove_int(avl, 339); - avl = grpc_avl_add(avl, box(809), box(123), nullptr); - avl = grpc_avl_add(avl, box(742), box(124), nullptr); - avl = grpc_avl_add(avl, box(718), box(125), nullptr); - avl = remove_int(avl, 988); - avl = remove_int(avl, 531); - avl = remove_int(avl, 840); - avl = grpc_avl_add(avl, box(816), box(129), nullptr); - avl = grpc_avl_add(avl, box(976), box(130), nullptr); - avl = remove_int(avl, 743); - avl = remove_int(avl, 528); - avl = remove_int(avl, 982); - avl = grpc_avl_add(avl, box(803), box(134), nullptr); - avl = grpc_avl_add(avl, box(205), box(135), nullptr); - avl = grpc_avl_add(avl, box(584), box(136), nullptr); - avl = remove_int(avl, 923); - avl = remove_int(avl, 538); - avl = remove_int(avl, 398); - avl = remove_int(avl, 320); - avl = remove_int(avl, 292); - avl = grpc_avl_add(avl, box(270), box(142), nullptr); - avl = grpc_avl_add(avl, box(333), box(143), nullptr); - avl = remove_int(avl, 439); - avl = grpc_avl_add(avl, box(35), box(145), nullptr); - avl = grpc_avl_add(avl, box(837), box(146), nullptr); - avl = remove_int(avl, 65); - avl = remove_int(avl, 642); - avl = remove_int(avl, 371); - avl = remove_int(avl, 140); - avl = remove_int(avl, 533); - avl = remove_int(avl, 676); - avl = grpc_avl_add(avl, box(624), box(153), nullptr); - avl = grpc_avl_add(avl, box(116), box(154), nullptr); - avl = grpc_avl_add(avl, box(446), box(155), nullptr); - avl = remove_int(avl, 91); - avl = remove_int(avl, 721); - avl = remove_int(avl, 537); - avl = grpc_avl_add(avl, box(448), box(159), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 344); - avl = remove_int(avl, 237); - avl = grpc_avl_add(avl, box(309), box(163), nullptr); - avl = grpc_avl_add(avl, box(434), box(164), nullptr); - avl = grpc_avl_add(avl, box(277), box(165), nullptr); - avl = remove_int(avl, 233); - avl = grpc_avl_add(avl, box(275), box(167), nullptr); - avl = grpc_avl_add(avl, box(218), box(168), nullptr); - avl = grpc_avl_add(avl, box(76), box(169), nullptr); - avl = grpc_avl_add(avl, box(898), box(170), nullptr); - avl = remove_int(avl, 771); - avl = grpc_avl_add(avl, box(237), box(172), nullptr); - avl = remove_int(avl, 327); - avl = grpc_avl_add(avl, box(499), box(174), nullptr); - avl = remove_int(avl, 727); - avl = remove_int(avl, 234); - avl = remove_int(avl, 623); - avl = remove_int(avl, 458); - avl = remove_int(avl, 326); - avl = remove_int(avl, 589); - avl = grpc_avl_add(avl, box(442), box(181), nullptr); - avl = remove_int(avl, 389); - avl = grpc_avl_add(avl, box(708), box(183), nullptr); - avl = grpc_avl_add(avl, box(594), box(184), nullptr); - avl = grpc_avl_add(avl, box(942), box(185), nullptr); - avl = grpc_avl_add(avl, box(282), box(186), nullptr); - avl = remove_int(avl, 434); - avl = remove_int(avl, 134); - avl = remove_int(avl, 270); - avl = remove_int(avl, 512); - avl = remove_int(avl, 265); - avl = remove_int(avl, 21); - avl = remove_int(avl, 193); - avl = remove_int(avl, 797); - avl = remove_int(avl, 347); - avl = grpc_avl_add(avl, box(99), box(196), nullptr); - avl = grpc_avl_add(avl, box(161), box(197), nullptr); - avl = remove_int(avl, 484); - avl = grpc_avl_add(avl, box(72), box(199), nullptr); - avl = remove_int(avl, 629); - avl = grpc_avl_add(avl, box(522), box(201), nullptr); - avl = remove_int(avl, 679); - avl = grpc_avl_add(avl, box(407), box(203), nullptr); - avl = remove_int(avl, 693); - avl = grpc_avl_add(avl, box(424), box(205), nullptr); - avl = grpc_avl_add(avl, box(651), box(206), nullptr); - avl = grpc_avl_add(avl, box(927), box(207), nullptr); - avl = remove_int(avl, 553); - avl = grpc_avl_add(avl, box(128), box(209), nullptr); - avl = grpc_avl_add(avl, box(616), box(210), nullptr); - avl = grpc_avl_add(avl, box(690), box(211), nullptr); - avl = remove_int(avl, 241); - avl = remove_int(avl, 179); - avl = grpc_avl_add(avl, box(697), box(214), nullptr); - avl = remove_int(avl, 779); - avl = grpc_avl_add(avl, box(241), box(216), nullptr); - avl = remove_int(avl, 190); - avl = remove_int(avl, 210); - avl = grpc_avl_add(avl, box(711), box(219), nullptr); - avl = remove_int(avl, 251); - avl = remove_int(avl, 61); - avl = grpc_avl_add(avl, box(800), box(222), nullptr); - avl = remove_int(avl, 551); - avl = grpc_avl_add(avl, box(61), box(224), nullptr); - avl = grpc_avl_add(avl, box(656), box(225), nullptr); - avl = remove_int(avl, 130); - avl = remove_int(avl, 368); - avl = remove_int(avl, 150); - avl = remove_int(avl, 73); - avl = grpc_avl_add(avl, box(799), box(230), nullptr); - avl = grpc_avl_add(avl, box(125), box(231), nullptr); - avl = remove_int(avl, 107); - avl = grpc_avl_add(avl, box(938), box(233), nullptr); - avl = grpc_avl_add(avl, box(914), box(234), nullptr); - avl = grpc_avl_add(avl, box(197), box(235), nullptr); - avl = remove_int(avl, 736); - avl = grpc_avl_add(avl, box(20), box(237), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 841); - avl = grpc_avl_add(avl, box(226), box(240), nullptr); - avl = remove_int(avl, 963); - avl = remove_int(avl, 796); - avl = remove_int(avl, 728); - avl = grpc_avl_add(avl, box(855), box(244), nullptr); - avl = grpc_avl_add(avl, box(769), box(245), nullptr); - avl = grpc_avl_add(avl, box(631), box(246), nullptr); - avl = remove_int(avl, 648); - avl = grpc_avl_add(avl, box(187), box(248), nullptr); - avl = grpc_avl_add(avl, box(31), box(249), nullptr); - avl = remove_int(avl, 163); - avl = grpc_avl_add(avl, box(218), box(251), nullptr); - avl = grpc_avl_add(avl, box(488), box(252), nullptr); - avl = grpc_avl_add(avl, box(387), box(253), nullptr); - avl = grpc_avl_add(avl, box(809), box(254), nullptr); - avl = grpc_avl_add(avl, box(997), box(255), nullptr); - avl = remove_int(avl, 678); - avl = grpc_avl_add(avl, box(368), box(257), nullptr); - avl = grpc_avl_add(avl, box(220), box(258), nullptr); - avl = grpc_avl_add(avl, box(373), box(259), nullptr); - avl = remove_int(avl, 874); - avl = remove_int(avl, 682); - avl = remove_int(avl, 1014); - avl = remove_int(avl, 195); - avl = grpc_avl_add(avl, box(868), box(264), nullptr); - avl = remove_int(avl, 254); - avl = remove_int(avl, 456); - avl = grpc_avl_add(avl, box(906), box(267), nullptr); - avl = remove_int(avl, 711); - avl = grpc_avl_add(avl, box(632), box(269), nullptr); - avl = remove_int(avl, 474); - avl = grpc_avl_add(avl, box(508), box(271), nullptr); - avl = grpc_avl_add(avl, box(518), box(272), nullptr); - avl = remove_int(avl, 579); - avl = remove_int(avl, 948); - avl = grpc_avl_add(avl, box(789), box(275), nullptr); - avl = grpc_avl_add(avl, box(48), box(276), nullptr); - avl = grpc_avl_add(avl, box(256), box(277), nullptr); - avl = grpc_avl_add(avl, box(754), box(278), nullptr); - avl = remove_int(avl, 215); - avl = grpc_avl_add(avl, box(679), box(280), nullptr); - avl = grpc_avl_add(avl, box(606), box(281), nullptr); - avl = remove_int(avl, 941); - avl = remove_int(avl, 31); - avl = grpc_avl_add(avl, box(758), box(284), nullptr); - avl = remove_int(avl, 101); - avl = grpc_avl_add(avl, box(244), box(286), nullptr); - avl = grpc_avl_add(avl, box(337), box(287), nullptr); - avl = grpc_avl_add(avl, box(461), box(288), nullptr); - avl = remove_int(avl, 476); - avl = grpc_avl_add(avl, box(845), box(290), nullptr); - avl = remove_int(avl, 160); - avl = grpc_avl_add(avl, box(690), box(292), nullptr); - avl = remove_int(avl, 931); - avl = grpc_avl_add(avl, box(869), box(294), nullptr); - avl = grpc_avl_add(avl, box(1019), box(295), nullptr); - avl = remove_int(avl, 591); - avl = remove_int(avl, 635); - avl = remove_int(avl, 67); - avl = grpc_avl_add(avl, box(113), box(299), nullptr); - avl = remove_int(avl, 305); - avl = grpc_avl_add(avl, box(10), box(301), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 288); - avl = remove_int(avl, 239); - avl = grpc_avl_add(avl, box(646), box(305), nullptr); - avl = grpc_avl_add(avl, box(1006), box(306), nullptr); - avl = grpc_avl_add(avl, box(954), box(307), nullptr); - avl = grpc_avl_add(avl, box(199), box(308), nullptr); - avl = grpc_avl_add(avl, box(69), box(309), nullptr); - avl = grpc_avl_add(avl, box(984), box(310), nullptr); - avl = remove_int(avl, 568); - avl = remove_int(avl, 666); - avl = remove_int(avl, 37); - avl = grpc_avl_add(avl, box(845), box(314), nullptr); - avl = remove_int(avl, 535); - avl = remove_int(avl, 365); - avl = remove_int(avl, 676); - avl = remove_int(avl, 892); - avl = remove_int(avl, 425); - avl = remove_int(avl, 704); - avl = remove_int(avl, 168); - avl = grpc_avl_add(avl, box(853), box(322), nullptr); - avl = grpc_avl_add(avl, box(335), box(323), nullptr); - avl = grpc_avl_add(avl, box(961), box(324), nullptr); - avl = grpc_avl_add(avl, box(73), box(325), nullptr); - avl = remove_int(avl, 469); - avl = grpc_avl_add(avl, box(449), box(327), nullptr); - avl = remove_int(avl, 821); - avl = grpc_avl_add(avl, box(845), box(329), nullptr); - avl = remove_int(avl, 637); - avl = grpc_avl_add(avl, box(769), box(331), nullptr); - avl = grpc_avl_add(avl, box(901), box(332), nullptr); - avl = remove_int(avl, 142); - avl = remove_int(avl, 361); - avl = remove_int(avl, 876); - avl = grpc_avl_add(avl, box(614), box(336), nullptr); - avl = grpc_avl_add(avl, box(729), box(337), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 473); - avl = remove_int(avl, 445); - avl = grpc_avl_add(avl, box(978), box(341), nullptr); - avl = grpc_avl_add(avl, box(164), box(342), nullptr); - avl = grpc_avl_add(avl, box(1), box(343), nullptr); - avl = remove_int(avl, 890); - avl = grpc_avl_add(avl, box(605), box(345), nullptr); - avl = grpc_avl_add(avl, box(178), box(346), nullptr); - avl = grpc_avl_add(avl, box(481), box(347), nullptr); - avl = grpc_avl_add(avl, box(772), box(348), nullptr); - avl = remove_int(avl, 824); - avl = remove_int(avl, 167); - avl = remove_int(avl, 151); - avl = grpc_avl_add(avl, box(698), box(352), nullptr); - avl = grpc_avl_add(avl, box(202), box(353), nullptr); - avl = grpc_avl_add(avl, box(921), box(354), nullptr); - avl = grpc_avl_add(avl, box(875), box(355), nullptr); - avl = remove_int(avl, 197); - avl = remove_int(avl, 232); - avl = grpc_avl_add(avl, box(209), box(358), nullptr); - avl = remove_int(avl, 324); - avl = remove_int(avl, 56); - avl = remove_int(avl, 579); - avl = remove_int(avl, 255); - avl = remove_int(avl, 290); - avl = grpc_avl_add(avl, box(661), box(364), nullptr); - avl = grpc_avl_add(avl, box(113), box(365), nullptr); - avl = remove_int(avl, 767); - avl = grpc_avl_add(avl, box(586), box(367), nullptr); - avl = grpc_avl_add(avl, box(121), box(368), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 439); - avl = remove_int(avl, 360); - avl = grpc_avl_add(avl, box(916), box(372), nullptr); - avl = remove_int(avl, 999); - avl = grpc_avl_add(avl, box(825), box(374), nullptr); - avl = grpc_avl_add(avl, box(177), box(375), nullptr); - avl = remove_int(avl, 204); - avl = remove_int(avl, 92); - avl = grpc_avl_add(avl, box(794), box(378), nullptr); - avl = grpc_avl_add(avl, box(463), box(379), nullptr); - avl = grpc_avl_add(avl, box(472), box(380), nullptr); - avl = remove_int(avl, 235); - avl = grpc_avl_add(avl, box(840), box(382), nullptr); - avl = remove_int(avl, 657); - avl = grpc_avl_add(avl, box(586), box(384), nullptr); - avl = grpc_avl_add(avl, box(979), box(385), nullptr); - avl = remove_int(avl, 979); - avl = grpc_avl_add(avl, box(639), box(387), nullptr); - avl = remove_int(avl, 907); - avl = remove_int(avl, 973); - avl = grpc_avl_add(avl, box(913), box(390), nullptr); - avl = grpc_avl_add(avl, box(566), box(391), nullptr); - avl = grpc_avl_add(avl, box(883), box(392), nullptr); - avl = grpc_avl_add(avl, box(552), box(393), nullptr); - avl = grpc_avl_add(avl, box(16), box(394), nullptr); - avl = remove_int(avl, 60); - avl = grpc_avl_add(avl, box(567), box(396), nullptr); - avl = grpc_avl_add(avl, box(705), box(397), nullptr); - avl = grpc_avl_add(avl, box(94), box(398), nullptr); - avl = remove_int(avl, 321); - avl = grpc_avl_add(avl, box(207), box(400), nullptr); - avl = grpc_avl_add(avl, box(682), box(401), nullptr); - avl = grpc_avl_add(avl, box(592), box(402), nullptr); - avl = grpc_avl_add(avl, box(10), box(403), nullptr); - avl = remove_int(avl, 911); - avl = remove_int(avl, 161); - avl = grpc_avl_add(avl, box(86), box(406), nullptr); - avl = remove_int(avl, 893); - avl = remove_int(avl, 362); - avl = grpc_avl_add(avl, box(599), box(409), nullptr); - avl = remove_int(avl, 413); - avl = grpc_avl_add(avl, box(867), box(411), nullptr); - avl = remove_int(avl, 955); - avl = grpc_avl_add(avl, box(341), box(413), nullptr); - avl = grpc_avl_add(avl, box(887), box(414), nullptr); - avl = remove_int(avl, 706); - avl = grpc_avl_add(avl, box(939), box(416), nullptr); - avl = remove_int(avl, 233); - avl = remove_int(avl, 662); - avl = remove_int(avl, 984); - avl = remove_int(avl, 203); - avl = grpc_avl_add(avl, box(326), box(421), nullptr); - avl = remove_int(avl, 848); - avl = grpc_avl_add(avl, box(235), box(423), nullptr); - avl = remove_int(avl, 617); - avl = grpc_avl_add(avl, box(565), box(425), nullptr); - avl = remove_int(avl, 469); - avl = grpc_avl_add(avl, box(988), box(427), nullptr); - avl = remove_int(avl, 957); - avl = grpc_avl_add(avl, box(426), box(429), nullptr); - avl = remove_int(avl, 967); - avl = grpc_avl_add(avl, box(890), box(431), nullptr); - avl = grpc_avl_add(avl, box(473), box(432), nullptr); - avl = remove_int(avl, 367); - avl = remove_int(avl, 344); - avl = remove_int(avl, 660); - avl = remove_int(avl, 448); - avl = remove_int(avl, 837); - avl = remove_int(avl, 158); - avl = grpc_avl_add(avl, box(459), box(439), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 782); - avl = grpc_avl_add(avl, box(408), box(442), nullptr); - avl = grpc_avl_add(avl, box(728), box(443), nullptr); - avl = remove_int(avl, 27); - avl = grpc_avl_add(avl, box(137), box(445), nullptr); - avl = grpc_avl_add(avl, box(239), box(446), nullptr); - avl = remove_int(avl, 854); - avl = grpc_avl_add(avl, box(104), box(448), nullptr); - avl = grpc_avl_add(avl, box(823), box(449), nullptr); - avl = grpc_avl_add(avl, box(524), box(450), nullptr); - avl = grpc_avl_add(avl, box(995), box(451), nullptr); - avl = remove_int(avl, 422); - avl = remove_int(avl, 220); - avl = grpc_avl_add(avl, box(856), box(454), nullptr); - avl = remove_int(avl, 332); - avl = grpc_avl_add(avl, box(679), box(456), nullptr); - avl = remove_int(avl, 18); - avl = grpc_avl_add(avl, box(837), box(458), nullptr); - avl = remove_int(avl, 405); - avl = remove_int(avl, 877); - avl = remove_int(avl, 835); - avl = grpc_avl_add(avl, box(547), box(462), nullptr); - avl = remove_int(avl, 805); - avl = remove_int(avl, 862); - avl = grpc_avl_add(avl, box(75), box(465), nullptr); - avl = remove_int(avl, 41); - avl = grpc_avl_add(avl, box(310), box(467), nullptr); - avl = remove_int(avl, 855); - avl = grpc_avl_add(avl, box(20), box(469), nullptr); - avl = remove_int(avl, 186); - avl = remove_int(avl, 378); - avl = remove_int(avl, 442); - avl = remove_int(avl, 930); - avl = grpc_avl_add(avl, box(118), box(474), nullptr); - avl = grpc_avl_add(avl, box(96), box(475), nullptr); - avl = remove_int(avl, 854); - avl = grpc_avl_add(avl, box(65), box(477), nullptr); - avl = grpc_avl_add(avl, box(573), box(478), nullptr); - avl = grpc_avl_add(avl, box(4), box(479), nullptr); - avl = grpc_avl_add(avl, box(451), box(480), nullptr); - avl = grpc_avl_add(avl, box(774), box(481), nullptr); - avl = grpc_avl_add(avl, box(126), box(482), nullptr); - avl = remove_int(avl, 956); - avl = remove_int(avl, 591); - avl = remove_int(avl, 644); - avl = grpc_avl_add(avl, box(304), box(486), nullptr); - avl = remove_int(avl, 620); - avl = remove_int(avl, 394); - avl = grpc_avl_add(avl, box(1002), box(489), nullptr); - avl = grpc_avl_add(avl, box(837), box(490), nullptr); - avl = remove_int(avl, 485); - avl = grpc_avl_add(avl, box(1005), box(492), nullptr); - avl = remove_int(avl, 21); - avl = grpc_avl_add(avl, box(396), box(494), nullptr); - avl = remove_int(avl, 966); - avl = grpc_avl_add(avl, box(105), box(496), nullptr); - avl = grpc_avl_add(avl, box(316), box(497), nullptr); - avl = remove_int(avl, 776); - avl = grpc_avl_add(avl, box(188), box(499), nullptr); - avl = remove_int(avl, 200); - avl = grpc_avl_add(avl, box(98), box(501), nullptr); - avl = grpc_avl_add(avl, box(831), box(502), nullptr); - avl = grpc_avl_add(avl, box(227), box(503), nullptr); - avl = grpc_avl_add(avl, box(220), box(504), nullptr); - avl = remove_int(avl, 715); - avl = remove_int(avl, 279); - avl = grpc_avl_add(avl, box(701), box(507), nullptr); - avl = grpc_avl_add(avl, box(726), box(508), nullptr); - avl = grpc_avl_add(avl, box(815), box(509), nullptr); - avl = grpc_avl_add(avl, box(749), box(510), nullptr); - avl = remove_int(avl, 946); - avl = remove_int(avl, 449); - avl = remove_int(avl, 62); - avl = remove_int(avl, 487); - avl = grpc_avl_add(avl, box(545), box(515), nullptr); - avl = remove_int(avl, 59); - avl = grpc_avl_add(avl, box(168), box(517), nullptr); - avl = remove_int(avl, 337); - avl = grpc_avl_add(avl, box(69), box(519), nullptr); - avl = remove_int(avl, 600); - avl = grpc_avl_add(avl, box(591), box(521), nullptr); - avl = grpc_avl_add(avl, box(960), box(522), nullptr); - avl = grpc_avl_add(avl, box(116), box(523), nullptr); - avl = remove_int(avl, 991); - avl = grpc_avl_add(avl, box(760), box(525), nullptr); - avl = grpc_avl_add(avl, box(664), box(526), nullptr); - avl = grpc_avl_add(avl, box(547), box(527), nullptr); - avl = remove_int(avl, 922); - avl = grpc_avl_add(avl, box(290), box(529), nullptr); - avl = grpc_avl_add(avl, box(859), box(530), nullptr); - avl = grpc_avl_add(avl, box(49), box(531), nullptr); - avl = remove_int(avl, 455); - avl = remove_int(avl, 786); - avl = grpc_avl_add(avl, box(613), box(534), nullptr); - avl = grpc_avl_add(avl, box(326), box(535), nullptr); - avl = remove_int(avl, 615); - avl = grpc_avl_add(avl, box(45), box(537), nullptr); - avl = grpc_avl_add(avl, box(162), box(538), nullptr); - avl = grpc_avl_add(avl, box(189), box(539), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 846); - avl = grpc_avl_add(avl, box(608), box(542), nullptr); - avl = remove_int(avl, 821); - avl = grpc_avl_add(avl, box(978), box(544), nullptr); - avl = grpc_avl_add(avl, box(892), box(545), nullptr); - avl = remove_int(avl, 924); - avl = grpc_avl_add(avl, box(708), box(547), nullptr); - avl = remove_int(avl, 135); - avl = remove_int(avl, 124); - avl = grpc_avl_add(avl, box(301), box(550), nullptr); - avl = grpc_avl_add(avl, box(939), box(551), nullptr); - avl = grpc_avl_add(avl, box(344), box(552), nullptr); - avl = remove_int(avl, 443); - avl = remove_int(avl, 122); - avl = grpc_avl_add(avl, box(636), box(555), nullptr); - avl = remove_int(avl, 558); - avl = grpc_avl_add(avl, box(923), box(557), nullptr); - avl = remove_int(avl, 827); - avl = grpc_avl_add(avl, box(649), box(559), nullptr); - avl = grpc_avl_add(avl, box(808), box(560), nullptr); - avl = remove_int(avl, 570); - avl = remove_int(avl, 434); - avl = grpc_avl_add(avl, box(40), box(563), nullptr); - avl = grpc_avl_add(avl, box(725), box(564), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 615); - avl = remove_int(avl, 919); - avl = remove_int(avl, 170); - avl = remove_int(avl, 442); - avl = remove_int(avl, 971); - avl = grpc_avl_add(avl, box(483), box(571), nullptr); - avl = grpc_avl_add(avl, box(512), box(572), nullptr); - avl = remove_int(avl, 648); - avl = remove_int(avl, 78); - avl = remove_int(avl, 72); - avl = remove_int(avl, 790); - avl = remove_int(avl, 571); - avl = grpc_avl_add(avl, box(898), box(578), nullptr); - avl = remove_int(avl, 770); - avl = remove_int(avl, 776); - avl = grpc_avl_add(avl, box(602), box(581), nullptr); - avl = remove_int(avl, 251); - avl = grpc_avl_add(avl, box(303), box(583), nullptr); - avl = remove_int(avl, 837); - avl = grpc_avl_add(avl, box(714), box(585), nullptr); - avl = remove_int(avl, 800); - avl = grpc_avl_add(avl, box(266), box(587), nullptr); - avl = grpc_avl_add(avl, box(555), box(588), nullptr); - avl = remove_int(avl, 604); - avl = remove_int(avl, 163); - avl = remove_int(avl, 497); - avl = grpc_avl_add(avl, box(296), box(592), nullptr); - avl = remove_int(avl, 129); - avl = grpc_avl_add(avl, box(656), box(594), nullptr); - avl = remove_int(avl, 769); - avl = remove_int(avl, 941); - avl = grpc_avl_add(avl, box(775), box(597), nullptr); - avl = grpc_avl_add(avl, box(846), box(598), nullptr); - avl = remove_int(avl, 591); - avl = remove_int(avl, 801); - avl = remove_int(avl, 419); - avl = remove_int(avl, 455); - avl = grpc_avl_add(avl, box(866), box(603), nullptr); - avl = grpc_avl_add(avl, box(575), box(604), nullptr); - avl = grpc_avl_add(avl, box(620), box(605), nullptr); - avl = remove_int(avl, 100); - avl = remove_int(avl, 667); - avl = grpc_avl_add(avl, box(138), box(608), nullptr); - avl = grpc_avl_add(avl, box(566), box(609), nullptr); - avl = grpc_avl_add(avl, box(673), box(610), nullptr); - avl = grpc_avl_add(avl, box(178), box(611), nullptr); - avl = remove_int(avl, 659); - avl = grpc_avl_add(avl, box(759), box(613), nullptr); - avl = grpc_avl_add(avl, box(1008), box(614), nullptr); - avl = remove_int(avl, 116); - avl = grpc_avl_add(avl, box(608), box(616), nullptr); - avl = grpc_avl_add(avl, box(339), box(617), nullptr); - avl = grpc_avl_add(avl, box(197), box(618), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 628); - avl = grpc_avl_add(avl, box(487), box(621), nullptr); - avl = remove_int(avl, 739); - avl = remove_int(avl, 100); - avl = remove_int(avl, 928); - avl = grpc_avl_add(avl, box(647), box(625), nullptr); - avl = remove_int(avl, 978); - avl = remove_int(avl, 143); - avl = remove_int(avl, 755); - avl = grpc_avl_add(avl, box(71), box(629), nullptr); - avl = remove_int(avl, 205); - avl = grpc_avl_add(avl, box(501), box(631), nullptr); - avl = remove_int(avl, 723); - avl = remove_int(avl, 852); - avl = remove_int(avl, 1021); - avl = remove_int(avl, 670); - avl = remove_int(avl, 500); - avl = grpc_avl_add(avl, box(330), box(637), nullptr); - avl = remove_int(avl, 264); - avl = grpc_avl_add(avl, box(69), box(639), nullptr); - avl = remove_int(avl, 73); - avl = grpc_avl_add(avl, box(745), box(641), nullptr); - avl = remove_int(avl, 518); - avl = remove_int(avl, 641); - avl = remove_int(avl, 768); - avl = grpc_avl_add(avl, box(988), box(645), nullptr); - avl = grpc_avl_add(avl, box(899), box(646), nullptr); - avl = remove_int(avl, 763); - avl = remove_int(avl, 281); - avl = remove_int(avl, 496); - avl = grpc_avl_add(avl, box(445), box(650), nullptr); - avl = remove_int(avl, 905); - avl = grpc_avl_add(avl, box(275), box(652), nullptr); - avl = grpc_avl_add(avl, box(137), box(653), nullptr); - avl = remove_int(avl, 642); - avl = grpc_avl_add(avl, box(708), box(655), nullptr); - avl = remove_int(avl, 922); - avl = grpc_avl_add(avl, box(743), box(657), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 665); - avl = remove_int(avl, 48); - avl = grpc_avl_add(avl, box(1012), box(661), nullptr); - avl = remove_int(avl, 71); - avl = remove_int(avl, 523); - avl = grpc_avl_add(avl, box(319), box(664), nullptr); - avl = remove_int(avl, 632); - avl = grpc_avl_add(avl, box(137), box(666), nullptr); - avl = grpc_avl_add(avl, box(686), box(667), nullptr); - avl = grpc_avl_add(avl, box(724), box(668), nullptr); - avl = grpc_avl_add(avl, box(952), box(669), nullptr); - avl = grpc_avl_add(avl, box(5), box(670), nullptr); - avl = remove_int(avl, 35); - avl = grpc_avl_add(avl, box(43), box(672), nullptr); - avl = grpc_avl_add(avl, box(320), box(673), nullptr); - avl = grpc_avl_add(avl, box(115), box(674), nullptr); - avl = remove_int(avl, 377); - avl = remove_int(avl, 591); - avl = remove_int(avl, 87); - avl = remove_int(avl, 93); - avl = grpc_avl_add(avl, box(1016), box(679), nullptr); - avl = grpc_avl_add(avl, box(605), box(680), nullptr); - avl = grpc_avl_add(avl, box(152), box(681), nullptr); - avl = grpc_avl_add(avl, box(113), box(682), nullptr); - avl = remove_int(avl, 131); - avl = remove_int(avl, 637); - avl = grpc_avl_add(avl, box(156), box(685), nullptr); - avl = remove_int(avl, 696); - avl = grpc_avl_add(avl, box(546), box(687), nullptr); - avl = remove_int(avl, 970); - avl = remove_int(avl, 53); - avl = remove_int(avl, 827); - avl = remove_int(avl, 224); - avl = remove_int(avl, 796); - avl = remove_int(avl, 34); - avl = remove_int(avl, 922); - avl = remove_int(avl, 277); - avl = remove_int(avl, 650); - avl = remove_int(avl, 222); - avl = remove_int(avl, 244); - avl = remove_int(avl, 576); - avl = remove_int(avl, 413); - avl = grpc_avl_add(avl, box(500), box(701), nullptr); - avl = remove_int(avl, 924); - avl = grpc_avl_add(avl, box(825), box(703), nullptr); - avl = remove_int(avl, 888); - avl = remove_int(avl, 931); - avl = grpc_avl_add(avl, box(285), box(706), nullptr); - avl = remove_int(avl, 62); - avl = remove_int(avl, 444); - avl = remove_int(avl, 946); - avl = grpc_avl_add(avl, box(122), box(710), nullptr); - avl = grpc_avl_add(avl, box(846), box(711), nullptr); - avl = remove_int(avl, 628); - avl = grpc_avl_add(avl, box(511), box(713), nullptr); - avl = grpc_avl_add(avl, box(398), box(714), nullptr); - avl = remove_int(avl, 730); - avl = grpc_avl_add(avl, box(797), box(716), nullptr); - avl = remove_int(avl, 897); - avl = remove_int(avl, 228); - avl = remove_int(avl, 544); - avl = remove_int(avl, 552); - avl = remove_int(avl, 783); - avl = remove_int(avl, 583); - avl = remove_int(avl, 894); - avl = remove_int(avl, 942); - avl = grpc_avl_add(avl, box(346), box(725), nullptr); - avl = grpc_avl_add(avl, box(1015), box(726), nullptr); - avl = remove_int(avl, 813); - avl = grpc_avl_add(avl, box(213), box(728), nullptr); - avl = remove_int(avl, 468); - avl = remove_int(avl, 365); - avl = remove_int(avl, 399); - avl = grpc_avl_add(avl, box(380), box(732), nullptr); - avl = remove_int(avl, 835); - avl = remove_int(avl, 970); - avl = grpc_avl_add(avl, box(700), box(735), nullptr); - avl = grpc_avl_add(avl, box(807), box(736), nullptr); - avl = remove_int(avl, 312); - avl = remove_int(avl, 282); - avl = remove_int(avl, 370); - avl = remove_int(avl, 999); - avl = remove_int(avl, 241); - avl = remove_int(avl, 884); - avl = grpc_avl_add(avl, box(587), box(743), nullptr); - avl = grpc_avl_add(avl, box(332), box(744), nullptr); - avl = remove_int(avl, 686); - avl = remove_int(avl, 206); - avl = remove_int(avl, 835); - avl = grpc_avl_add(avl, box(334), box(748), nullptr); - avl = remove_int(avl, 171); - avl = grpc_avl_add(avl, box(1002), box(750), nullptr); - avl = grpc_avl_add(avl, box(779), box(751), nullptr); - avl = grpc_avl_add(avl, box(307), box(752), nullptr); - avl = grpc_avl_add(avl, box(127), box(753), nullptr); - avl = grpc_avl_add(avl, box(251), box(754), nullptr); - avl = remove_int(avl, 790); - avl = remove_int(avl, 189); - avl = remove_int(avl, 193); - avl = remove_int(avl, 38); - avl = remove_int(avl, 124); - avl = grpc_avl_add(avl, box(812), box(760), nullptr); - avl = remove_int(avl, 43); - avl = grpc_avl_add(avl, box(871), box(762), nullptr); - avl = grpc_avl_add(avl, box(580), box(763), nullptr); - avl = remove_int(avl, 501); - avl = remove_int(avl, 462); - avl = remove_int(avl, 599); - avl = grpc_avl_add(avl, box(240), box(767), nullptr); - avl = grpc_avl_add(avl, box(285), box(768), nullptr); - avl = grpc_avl_add(avl, box(472), box(769), nullptr); - avl = remove_int(avl, 865); - avl = remove_int(avl, 763); - avl = remove_int(avl, 245); - avl = remove_int(avl, 80); - avl = remove_int(avl, 713); - avl = remove_int(avl, 654); - avl = remove_int(avl, 1014); - avl = grpc_avl_add(avl, box(495), box(777), nullptr); - avl = grpc_avl_add(avl, box(552), box(778), nullptr); - avl = remove_int(avl, 19); - avl = remove_int(avl, 803); - avl = grpc_avl_add(avl, box(508), box(781), nullptr); - avl = remove_int(avl, 699); - avl = remove_int(avl, 260); - avl = remove_int(avl, 92); - avl = remove_int(avl, 497); - avl = grpc_avl_add(avl, box(970), box(786), nullptr); - avl = remove_int(avl, 987); - avl = remove_int(avl, 168); - avl = remove_int(avl, 476); - avl = remove_int(avl, 248); - avl = grpc_avl_add(avl, box(358), box(791), nullptr); - avl = remove_int(avl, 804); - avl = remove_int(avl, 77); - avl = remove_int(avl, 905); - avl = remove_int(avl, 362); - avl = grpc_avl_add(avl, box(578), box(796), nullptr); - avl = remove_int(avl, 38); - avl = remove_int(avl, 595); - avl = grpc_avl_add(avl, box(213), box(799), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 620); - avl = grpc_avl_add(avl, box(946), box(802), nullptr); - avl = remove_int(avl, 145); - avl = grpc_avl_add(avl, box(628), box(804), nullptr); - avl = remove_int(avl, 972); - avl = grpc_avl_add(avl, box(728), box(806), nullptr); - avl = remove_int(avl, 91); - avl = grpc_avl_add(avl, box(136), box(808), nullptr); - avl = grpc_avl_add(avl, box(841), box(809), nullptr); - avl = grpc_avl_add(avl, box(265), box(810), nullptr); - avl = grpc_avl_add(avl, box(701), box(811), nullptr); - avl = grpc_avl_add(avl, box(27), box(812), nullptr); - avl = remove_int(avl, 72); - avl = remove_int(avl, 14); - avl = grpc_avl_add(avl, box(286), box(815), nullptr); - avl = remove_int(avl, 996); - avl = remove_int(avl, 998); - avl = grpc_avl_add(avl, box(466), box(818), nullptr); - avl = remove_int(avl, 1009); - avl = remove_int(avl, 741); - avl = remove_int(avl, 947); - avl = remove_int(avl, 241); - avl = remove_int(avl, 954); - avl = remove_int(avl, 183); - avl = remove_int(avl, 395); - avl = remove_int(avl, 951); - avl = grpc_avl_add(avl, box(267), box(827), nullptr); - avl = remove_int(avl, 812); - avl = grpc_avl_add(avl, box(577), box(829), nullptr); - avl = remove_int(avl, 624); - avl = remove_int(avl, 847); - avl = remove_int(avl, 745); - avl = grpc_avl_add(avl, box(491), box(833), nullptr); - avl = grpc_avl_add(avl, box(941), box(834), nullptr); - avl = remove_int(avl, 258); - avl = grpc_avl_add(avl, box(410), box(836), nullptr); - avl = grpc_avl_add(avl, box(80), box(837), nullptr); - avl = grpc_avl_add(avl, box(196), box(838), nullptr); - avl = grpc_avl_add(avl, box(5), box(839), nullptr); - avl = remove_int(avl, 782); - avl = grpc_avl_add(avl, box(827), box(841), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 664); - avl = grpc_avl_add(avl, box(409), box(844), nullptr); - avl = grpc_avl_add(avl, box(62), box(845), nullptr); - avl = remove_int(avl, 56); - avl = remove_int(avl, 606); - avl = remove_int(avl, 707); - avl = remove_int(avl, 989); - avl = remove_int(avl, 549); - avl = remove_int(avl, 259); - avl = grpc_avl_add(avl, box(405), box(852), nullptr); - avl = remove_int(avl, 587); - avl = remove_int(avl, 350); - avl = grpc_avl_add(avl, box(980), box(855), nullptr); - avl = grpc_avl_add(avl, box(992), box(856), nullptr); - avl = grpc_avl_add(avl, box(818), box(857), nullptr); - avl = remove_int(avl, 853); - avl = remove_int(avl, 701); - avl = grpc_avl_add(avl, box(675), box(860), nullptr); - avl = remove_int(avl, 248); - avl = remove_int(avl, 649); - avl = grpc_avl_add(avl, box(508), box(863), nullptr); - avl = remove_int(avl, 927); - avl = grpc_avl_add(avl, box(957), box(865), nullptr); - avl = grpc_avl_add(avl, box(698), box(866), nullptr); - avl = grpc_avl_add(avl, box(388), box(867), nullptr); - avl = grpc_avl_add(avl, box(532), box(868), nullptr); - avl = grpc_avl_add(avl, box(681), box(869), nullptr); - avl = remove_int(avl, 544); - avl = remove_int(avl, 991); - avl = remove_int(avl, 397); - avl = grpc_avl_add(avl, box(954), box(873), nullptr); - avl = grpc_avl_add(avl, box(219), box(874), nullptr); - avl = grpc_avl_add(avl, box(465), box(875), nullptr); - avl = remove_int(avl, 371); - avl = grpc_avl_add(avl, box(601), box(877), nullptr); - avl = grpc_avl_add(avl, box(543), box(878), nullptr); - avl = remove_int(avl, 329); - avl = grpc_avl_add(avl, box(560), box(880), nullptr); - avl = remove_int(avl, 898); - avl = grpc_avl_add(avl, box(455), box(882), nullptr); - avl = remove_int(avl, 313); - avl = grpc_avl_add(avl, box(215), box(884), nullptr); - avl = remove_int(avl, 846); - avl = grpc_avl_add(avl, box(608), box(886), nullptr); - avl = remove_int(avl, 248); - avl = grpc_avl_add(avl, box(575), box(888), nullptr); - avl = remove_int(avl, 207); - avl = remove_int(avl, 810); - avl = remove_int(avl, 665); - avl = remove_int(avl, 361); - avl = grpc_avl_add(avl, box(154), box(893), nullptr); - avl = grpc_avl_add(avl, box(329), box(894), nullptr); - avl = grpc_avl_add(avl, box(326), box(895), nullptr); - avl = remove_int(avl, 746); - avl = remove_int(avl, 99); - avl = grpc_avl_add(avl, box(464), box(898), nullptr); - avl = grpc_avl_add(avl, box(141), box(899), nullptr); - avl = remove_int(avl, 383); - avl = grpc_avl_add(avl, box(414), box(901), nullptr); - avl = grpc_avl_add(avl, box(777), box(902), nullptr); - avl = remove_int(avl, 972); - avl = remove_int(avl, 841); - avl = remove_int(avl, 100); - avl = grpc_avl_add(avl, box(828), box(906), nullptr); - avl = remove_int(avl, 785); - avl = grpc_avl_add(avl, box(1008), box(908), nullptr); - avl = grpc_avl_add(avl, box(46), box(909), nullptr); - avl = remove_int(avl, 399); - avl = grpc_avl_add(avl, box(178), box(911), nullptr); - avl = grpc_avl_add(avl, box(573), box(912), nullptr); - avl = remove_int(avl, 299); - avl = grpc_avl_add(avl, box(690), box(914), nullptr); - avl = grpc_avl_add(avl, box(692), box(915), nullptr); - avl = remove_int(avl, 404); - avl = remove_int(avl, 16); - avl = remove_int(avl, 746); - avl = remove_int(avl, 486); - avl = remove_int(avl, 119); - avl = grpc_avl_add(avl, box(167), box(921), nullptr); - avl = remove_int(avl, 328); - avl = grpc_avl_add(avl, box(89), box(923), nullptr); - avl = remove_int(avl, 867); - avl = remove_int(avl, 626); - avl = remove_int(avl, 507); - avl = grpc_avl_add(avl, box(365), box(927), nullptr); - avl = grpc_avl_add(avl, box(58), box(928), nullptr); - avl = grpc_avl_add(avl, box(70), box(929), nullptr); - avl = remove_int(avl, 81); - avl = remove_int(avl, 797); - avl = grpc_avl_add(avl, box(846), box(932), nullptr); - avl = remove_int(avl, 642); - avl = grpc_avl_add(avl, box(777), box(934), nullptr); - avl = remove_int(avl, 107); - avl = grpc_avl_add(avl, box(691), box(936), nullptr); - avl = grpc_avl_add(avl, box(820), box(937), nullptr); - avl = grpc_avl_add(avl, box(202), box(938), nullptr); - avl = grpc_avl_add(avl, box(308), box(939), nullptr); - avl = grpc_avl_add(avl, box(20), box(940), nullptr); - avl = remove_int(avl, 289); - avl = grpc_avl_add(avl, box(714), box(942), nullptr); - avl = grpc_avl_add(avl, box(584), box(943), nullptr); - avl = remove_int(avl, 294); - avl = grpc_avl_add(avl, box(496), box(945), nullptr); - avl = grpc_avl_add(avl, box(394), box(946), nullptr); - avl = grpc_avl_add(avl, box(860), box(947), nullptr); - avl = grpc_avl_add(avl, box(58), box(948), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 584); - avl = remove_int(avl, 708); - avl = grpc_avl_add(avl, box(142), box(952), nullptr); - avl = grpc_avl_add(avl, box(247), box(953), nullptr); - avl = grpc_avl_add(avl, box(389), box(954), nullptr); - avl = remove_int(avl, 390); - avl = grpc_avl_add(avl, box(465), box(956), nullptr); - avl = grpc_avl_add(avl, box(936), box(957), nullptr); - avl = grpc_avl_add(avl, box(309), box(958), nullptr); - avl = remove_int(avl, 928); - avl = remove_int(avl, 128); - avl = remove_int(avl, 979); - avl = remove_int(avl, 670); - avl = remove_int(avl, 738); - avl = remove_int(avl, 271); - avl = remove_int(avl, 540); - avl = grpc_avl_add(avl, box(365), box(966), nullptr); - avl = remove_int(avl, 82); - avl = grpc_avl_add(avl, box(728), box(968), nullptr); - avl = remove_int(avl, 852); - avl = grpc_avl_add(avl, box(884), box(970), nullptr); - avl = grpc_avl_add(avl, box(502), box(971), nullptr); - avl = remove_int(avl, 898); - avl = remove_int(avl, 481); - avl = grpc_avl_add(avl, box(911), box(974), nullptr); - avl = remove_int(avl, 787); - avl = remove_int(avl, 785); - avl = remove_int(avl, 537); - avl = remove_int(avl, 535); - avl = remove_int(avl, 136); - avl = remove_int(avl, 749); - avl = remove_int(avl, 637); - avl = remove_int(avl, 900); - avl = grpc_avl_add(avl, box(598), box(983), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 697); - avl = grpc_avl_add(avl, box(645), box(986), nullptr); - avl = grpc_avl_add(avl, box(211), box(987), nullptr); - avl = grpc_avl_add(avl, box(589), box(988), nullptr); - avl = remove_int(avl, 702); - avl = grpc_avl_add(avl, box(53), box(990), nullptr); - avl = remove_int(avl, 492); - avl = remove_int(avl, 185); - avl = remove_int(avl, 246); - avl = remove_int(avl, 257); - avl = remove_int(avl, 502); - avl = remove_int(avl, 34); - avl = grpc_avl_add(avl, box(74), box(997), nullptr); - avl = grpc_avl_add(avl, box(834), box(998), nullptr); - avl = grpc_avl_add(avl, box(514), box(999), nullptr); - avl = grpc_avl_add(avl, box(75), box(1000), nullptr); - avl = remove_int(avl, 745); - avl = grpc_avl_add(avl, box(362), box(1002), nullptr); - avl = remove_int(avl, 215); - avl = grpc_avl_add(avl, box(624), box(1004), nullptr); - avl = remove_int(avl, 404); - avl = remove_int(avl, 359); - avl = remove_int(avl, 491); - avl = grpc_avl_add(avl, box(903), box(1008), nullptr); - avl = grpc_avl_add(avl, box(240), box(1009), nullptr); - avl = remove_int(avl, 95); - avl = grpc_avl_add(avl, box(119), box(1011), nullptr); - avl = grpc_avl_add(avl, box(857), box(1012), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 866); - avl = grpc_avl_add(avl, box(503), box(1015), nullptr); - avl = grpc_avl_add(avl, box(740), box(1016), nullptr); - avl = remove_int(avl, 637); - avl = remove_int(avl, 156); - avl = remove_int(avl, 6); - avl = remove_int(avl, 745); - avl = remove_int(avl, 433); - avl = remove_int(avl, 283); - avl = grpc_avl_add(avl, box(625), box(1023), nullptr); - avl = remove_int(avl, 638); - avl = grpc_avl_add(avl, box(299), box(1025), nullptr); - avl = grpc_avl_add(avl, box(584), box(1026), nullptr); - avl = remove_int(avl, 863); - avl = grpc_avl_add(avl, box(612), box(1028), nullptr); - avl = grpc_avl_add(avl, box(62), box(1029), nullptr); - avl = grpc_avl_add(avl, box(432), box(1030), nullptr); - avl = remove_int(avl, 371); - avl = remove_int(avl, 790); - avl = remove_int(avl, 227); - avl = remove_int(avl, 836); - avl = grpc_avl_add(avl, box(703), box(1035), nullptr); - avl = grpc_avl_add(avl, box(644), box(1036), nullptr); - avl = remove_int(avl, 638); - avl = grpc_avl_add(avl, box(13), box(1038), nullptr); - avl = remove_int(avl, 66); - avl = remove_int(avl, 82); - avl = grpc_avl_add(avl, box(362), box(1041), nullptr); - avl = grpc_avl_add(avl, box(783), box(1042), nullptr); - avl = remove_int(avl, 60); - avl = grpc_avl_add(avl, box(80), box(1044), nullptr); - avl = grpc_avl_add(avl, box(825), box(1045), nullptr); - avl = grpc_avl_add(avl, box(688), box(1046), nullptr); - avl = grpc_avl_add(avl, box(662), box(1047), nullptr); - avl = remove_int(avl, 156); - avl = remove_int(avl, 376); - avl = remove_int(avl, 99); - avl = grpc_avl_add(avl, box(526), box(1051), nullptr); - avl = grpc_avl_add(avl, box(168), box(1052), nullptr); - avl = remove_int(avl, 646); - avl = remove_int(avl, 380); - avl = remove_int(avl, 833); - avl = grpc_avl_add(avl, box(53), box(1056), nullptr); - avl = remove_int(avl, 105); - avl = grpc_avl_add(avl, box(373), box(1058), nullptr); - avl = grpc_avl_add(avl, box(184), box(1059), nullptr); - avl = remove_int(avl, 288); - avl = grpc_avl_add(avl, box(966), box(1061), nullptr); - avl = remove_int(avl, 158); - avl = grpc_avl_add(avl, box(406), box(1063), nullptr); - avl = remove_int(avl, 470); - avl = grpc_avl_add(avl, box(283), box(1065), nullptr); - avl = grpc_avl_add(avl, box(838), box(1066), nullptr); - avl = grpc_avl_add(avl, box(288), box(1067), nullptr); - avl = grpc_avl_add(avl, box(950), box(1068), nullptr); - avl = grpc_avl_add(avl, box(163), box(1069), nullptr); - avl = remove_int(avl, 623); - avl = remove_int(avl, 769); - avl = grpc_avl_add(avl, box(144), box(1072), nullptr); - avl = grpc_avl_add(avl, box(489), box(1073), nullptr); - avl = remove_int(avl, 15); - avl = grpc_avl_add(avl, box(971), box(1075), nullptr); - avl = remove_int(avl, 660); - avl = grpc_avl_add(avl, box(255), box(1077), nullptr); - avl = remove_int(avl, 494); - avl = grpc_avl_add(avl, box(109), box(1079), nullptr); - avl = grpc_avl_add(avl, box(420), box(1080), nullptr); - avl = grpc_avl_add(avl, box(509), box(1081), nullptr); - avl = remove_int(avl, 178); - avl = grpc_avl_add(avl, box(216), box(1083), nullptr); - avl = grpc_avl_add(avl, box(707), box(1084), nullptr); - avl = grpc_avl_add(avl, box(411), box(1085), nullptr); - avl = grpc_avl_add(avl, box(352), box(1086), nullptr); - avl = remove_int(avl, 983); - avl = grpc_avl_add(avl, box(6), box(1088), nullptr); - avl = grpc_avl_add(avl, box(1014), box(1089), nullptr); - avl = remove_int(avl, 98); - avl = remove_int(avl, 325); - avl = grpc_avl_add(avl, box(851), box(1092), nullptr); - avl = remove_int(avl, 553); - avl = grpc_avl_add(avl, box(218), box(1094), nullptr); - avl = grpc_avl_add(avl, box(261), box(1095), nullptr); - avl = remove_int(avl, 31); - avl = grpc_avl_add(avl, box(872), box(1097), nullptr); - avl = remove_int(avl, 543); - avl = remove_int(avl, 314); - avl = remove_int(avl, 443); - avl = grpc_avl_add(avl, box(533), box(1101), nullptr); - avl = remove_int(avl, 881); - avl = remove_int(avl, 269); - avl = remove_int(avl, 940); - avl = remove_int(avl, 909); - avl = remove_int(avl, 197); - avl = remove_int(avl, 773); - avl = remove_int(avl, 790); - avl = remove_int(avl, 345); - avl = grpc_avl_add(avl, box(965), box(1110), nullptr); - avl = remove_int(avl, 622); - avl = grpc_avl_add(avl, box(352), box(1112), nullptr); - avl = remove_int(avl, 182); - avl = grpc_avl_add(avl, box(534), box(1114), nullptr); - avl = grpc_avl_add(avl, box(97), box(1115), nullptr); - avl = grpc_avl_add(avl, box(198), box(1116), nullptr); - avl = remove_int(avl, 750); - avl = grpc_avl_add(avl, box(98), box(1118), nullptr); - avl = remove_int(avl, 943); - avl = grpc_avl_add(avl, box(254), box(1120), nullptr); - avl = grpc_avl_add(avl, box(30), box(1121), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 475); - avl = remove_int(avl, 82); - avl = grpc_avl_add(avl, box(789), box(1125), nullptr); - avl = grpc_avl_add(avl, box(402), box(1126), nullptr); - avl = remove_int(avl, 1019); - avl = grpc_avl_add(avl, box(858), box(1128), nullptr); - avl = grpc_avl_add(avl, box(625), box(1129), nullptr); - avl = remove_int(avl, 675); - avl = remove_int(avl, 323); - avl = grpc_avl_add(avl, box(329), box(1132), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 44); - avl = grpc_avl_add(avl, box(443), box(1135), nullptr); - avl = grpc_avl_add(avl, box(653), box(1136), nullptr); - avl = grpc_avl_add(avl, box(750), box(1137), nullptr); - avl = grpc_avl_add(avl, box(252), box(1138), nullptr); - avl = grpc_avl_add(avl, box(449), box(1139), nullptr); - avl = remove_int(avl, 1022); - avl = remove_int(avl, 357); - avl = remove_int(avl, 602); - avl = remove_int(avl, 131); - avl = grpc_avl_add(avl, box(531), box(1144), nullptr); - avl = remove_int(avl, 806); - avl = grpc_avl_add(avl, box(455), box(1146), nullptr); - avl = remove_int(avl, 31); - avl = grpc_avl_add(avl, box(154), box(1148), nullptr); - avl = grpc_avl_add(avl, box(189), box(1149), nullptr); - avl = remove_int(avl, 786); - avl = grpc_avl_add(avl, box(496), box(1151), nullptr); - avl = grpc_avl_add(avl, box(81), box(1152), nullptr); - avl = grpc_avl_add(avl, box(59), box(1153), nullptr); - avl = remove_int(avl, 424); - avl = remove_int(avl, 668); - avl = grpc_avl_add(avl, box(723), box(1156), nullptr); - avl = grpc_avl_add(avl, box(822), box(1157), nullptr); - avl = grpc_avl_add(avl, box(354), box(1158), nullptr); - avl = remove_int(avl, 738); - avl = grpc_avl_add(avl, box(686), box(1160), nullptr); - avl = grpc_avl_add(avl, box(43), box(1161), nullptr); - avl = grpc_avl_add(avl, box(625), box(1162), nullptr); - avl = grpc_avl_add(avl, box(902), box(1163), nullptr); - avl = grpc_avl_add(avl, box(12), box(1164), nullptr); - avl = grpc_avl_add(avl, box(977), box(1165), nullptr); - avl = grpc_avl_add(avl, box(699), box(1166), nullptr); - avl = grpc_avl_add(avl, box(189), box(1167), nullptr); - avl = remove_int(avl, 672); - avl = remove_int(avl, 90); - avl = remove_int(avl, 757); - avl = remove_int(avl, 494); - avl = grpc_avl_add(avl, box(759), box(1172), nullptr); - avl = remove_int(avl, 758); - avl = remove_int(avl, 222); - avl = grpc_avl_add(avl, box(975), box(1175), nullptr); - avl = remove_int(avl, 993); - avl = grpc_avl_add(avl, box(2), box(1177), nullptr); - avl = grpc_avl_add(avl, box(70), box(1178), nullptr); - avl = remove_int(avl, 350); - avl = remove_int(avl, 972); - avl = remove_int(avl, 880); - avl = grpc_avl_add(avl, box(753), box(1182), nullptr); - avl = remove_int(avl, 404); - avl = grpc_avl_add(avl, box(294), box(1184), nullptr); - avl = remove_int(avl, 474); - avl = grpc_avl_add(avl, box(228), box(1186), nullptr); - avl = grpc_avl_add(avl, box(484), box(1187), nullptr); - avl = remove_int(avl, 238); - avl = remove_int(avl, 53); - avl = remove_int(avl, 691); - avl = grpc_avl_add(avl, box(345), box(1191), nullptr); - avl = remove_int(avl, 0); - avl = grpc_avl_add(avl, box(230), box(1193), nullptr); - avl = remove_int(avl, 227); - avl = remove_int(avl, 152); - avl = grpc_avl_add(avl, box(884), box(1196), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 53); - avl = grpc_avl_add(avl, box(1015), box(1199), nullptr); - avl = grpc_avl_add(avl, box(697), box(1200), nullptr); - avl = grpc_avl_add(avl, box(376), box(1201), nullptr); - avl = remove_int(avl, 411); - avl = grpc_avl_add(avl, box(888), box(1203), nullptr); - avl = remove_int(avl, 55); - avl = grpc_avl_add(avl, box(85), box(1205), nullptr); - avl = remove_int(avl, 947); - avl = remove_int(avl, 382); - avl = remove_int(avl, 777); - avl = grpc_avl_add(avl, box(1017), box(1209), nullptr); - avl = grpc_avl_add(avl, box(169), box(1210), nullptr); - avl = grpc_avl_add(avl, box(156), box(1211), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 642); - avl = remove_int(avl, 158); - avl = grpc_avl_add(avl, box(554), box(1215), nullptr); - avl = grpc_avl_add(avl, box(76), box(1216), nullptr); - avl = grpc_avl_add(avl, box(756), box(1217), nullptr); - avl = remove_int(avl, 767); - avl = remove_int(avl, 112); - avl = remove_int(avl, 539); - avl = remove_int(avl, 544); - avl = remove_int(avl, 628); - avl = remove_int(avl, 385); - avl = remove_int(avl, 514); - avl = remove_int(avl, 362); - avl = grpc_avl_add(avl, box(523), box(1226), nullptr); - avl = grpc_avl_add(avl, box(712), box(1227), nullptr); - avl = grpc_avl_add(avl, box(474), box(1228), nullptr); - avl = grpc_avl_add(avl, box(882), box(1229), nullptr); - avl = grpc_avl_add(avl, box(965), box(1230), nullptr); - avl = remove_int(avl, 464); - avl = grpc_avl_add(avl, box(319), box(1232), nullptr); - avl = grpc_avl_add(avl, box(504), box(1233), nullptr); - avl = remove_int(avl, 818); - avl = grpc_avl_add(avl, box(884), box(1235), nullptr); - avl = grpc_avl_add(avl, box(813), box(1236), nullptr); - avl = grpc_avl_add(avl, box(795), box(1237), nullptr); - avl = remove_int(avl, 306); - avl = grpc_avl_add(avl, box(799), box(1239), nullptr); - avl = remove_int(avl, 534); - avl = grpc_avl_add(avl, box(480), box(1241), nullptr); - avl = grpc_avl_add(avl, box(656), box(1242), nullptr); - avl = grpc_avl_add(avl, box(709), box(1243), nullptr); - avl = grpc_avl_add(avl, box(500), box(1244), nullptr); - avl = remove_int(avl, 740); - avl = grpc_avl_add(avl, box(980), box(1246), nullptr); - avl = grpc_avl_add(avl, box(458), box(1247), nullptr); - avl = remove_int(avl, 377); - avl = remove_int(avl, 338); - avl = grpc_avl_add(avl, box(554), box(1250), nullptr); - avl = grpc_avl_add(avl, box(504), box(1251), nullptr); - avl = grpc_avl_add(avl, box(603), box(1252), nullptr); - avl = grpc_avl_add(avl, box(761), box(1253), nullptr); - avl = remove_int(avl, 431); - avl = grpc_avl_add(avl, box(707), box(1255), nullptr); - avl = grpc_avl_add(avl, box(673), box(1256), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 332); - avl = remove_int(avl, 413); - avl = remove_int(avl, 227); - avl = remove_int(avl, 249); - avl = remove_int(avl, 309); - avl = remove_int(avl, 459); - avl = grpc_avl_add(avl, box(645), box(1264), nullptr); - avl = remove_int(avl, 858); - avl = remove_int(avl, 997); - avl = grpc_avl_add(avl, box(519), box(1267), nullptr); - avl = remove_int(avl, 614); - avl = remove_int(avl, 462); - avl = remove_int(avl, 792); - avl = grpc_avl_add(avl, box(987), box(1271), nullptr); - avl = grpc_avl_add(avl, box(309), box(1272), nullptr); - avl = remove_int(avl, 747); - avl = grpc_avl_add(avl, box(621), box(1274), nullptr); - avl = grpc_avl_add(avl, box(450), box(1275), nullptr); - avl = remove_int(avl, 265); - avl = remove_int(avl, 8); - avl = remove_int(avl, 383); - avl = grpc_avl_add(avl, box(238), box(1279), nullptr); - avl = remove_int(avl, 241); - avl = grpc_avl_add(avl, box(180), box(1281), nullptr); - avl = grpc_avl_add(avl, box(411), box(1282), nullptr); - avl = grpc_avl_add(avl, box(791), box(1283), nullptr); - avl = grpc_avl_add(avl, box(955), box(1284), nullptr); - avl = remove_int(avl, 24); - avl = remove_int(avl, 375); - avl = grpc_avl_add(avl, box(140), box(1287), nullptr); - avl = remove_int(avl, 949); - avl = grpc_avl_add(avl, box(301), box(1289), nullptr); - avl = grpc_avl_add(avl, box(0), box(1290), nullptr); - avl = remove_int(avl, 371); - avl = remove_int(avl, 427); - avl = remove_int(avl, 841); - avl = remove_int(avl, 847); - avl = grpc_avl_add(avl, box(814), box(1295), nullptr); - avl = grpc_avl_add(avl, box(127), box(1296), nullptr); - avl = grpc_avl_add(avl, box(279), box(1297), nullptr); - avl = remove_int(avl, 669); - avl = remove_int(avl, 541); - avl = remove_int(avl, 275); - avl = remove_int(avl, 299); - avl = remove_int(avl, 552); - avl = grpc_avl_add(avl, box(310), box(1303), nullptr); - avl = grpc_avl_add(avl, box(304), box(1304), nullptr); - avl = grpc_avl_add(avl, box(1), box(1305), nullptr); - avl = grpc_avl_add(avl, box(339), box(1306), nullptr); - avl = remove_int(avl, 570); - avl = remove_int(avl, 752); - avl = remove_int(avl, 552); - avl = remove_int(avl, 442); - avl = remove_int(avl, 639); - avl = grpc_avl_add(avl, box(313), box(1312), nullptr); - avl = remove_int(avl, 85); - avl = grpc_avl_add(avl, box(964), box(1314), nullptr); - avl = grpc_avl_add(avl, box(559), box(1315), nullptr); - avl = remove_int(avl, 167); - avl = grpc_avl_add(avl, box(866), box(1317), nullptr); - avl = remove_int(avl, 275); - avl = grpc_avl_add(avl, box(173), box(1319), nullptr); - avl = grpc_avl_add(avl, box(765), box(1320), nullptr); - avl = remove_int(avl, 883); - avl = grpc_avl_add(avl, box(547), box(1322), nullptr); - avl = grpc_avl_add(avl, box(847), box(1323), nullptr); - avl = remove_int(avl, 817); - avl = remove_int(avl, 850); - avl = remove_int(avl, 718); - avl = grpc_avl_add(avl, box(806), box(1327), nullptr); - avl = grpc_avl_add(avl, box(360), box(1328), nullptr); - avl = remove_int(avl, 991); - avl = grpc_avl_add(avl, box(493), box(1330), nullptr); - avl = remove_int(avl, 516); - avl = grpc_avl_add(avl, box(361), box(1332), nullptr); - avl = remove_int(avl, 355); - avl = grpc_avl_add(avl, box(512), box(1334), nullptr); - avl = grpc_avl_add(avl, box(191), box(1335), nullptr); - avl = remove_int(avl, 703); - avl = grpc_avl_add(avl, box(333), box(1337), nullptr); - avl = remove_int(avl, 481); - avl = grpc_avl_add(avl, box(501), box(1339), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 510); - avl = grpc_avl_add(avl, box(793), box(1342), nullptr); - avl = grpc_avl_add(avl, box(234), box(1343), nullptr); - avl = remove_int(avl, 159); - avl = remove_int(avl, 429); - avl = remove_int(avl, 728); - avl = remove_int(avl, 288); - avl = grpc_avl_add(avl, box(281), box(1348), nullptr); - avl = grpc_avl_add(avl, box(702), box(1349), nullptr); - avl = grpc_avl_add(avl, box(149), box(1350), nullptr); - avl = remove_int(avl, 22); - avl = remove_int(avl, 944); - avl = remove_int(avl, 55); - avl = remove_int(avl, 512); - avl = remove_int(avl, 676); - avl = remove_int(avl, 884); - avl = grpc_avl_add(avl, box(246), box(1357), nullptr); - avl = grpc_avl_add(avl, box(455), box(1358), nullptr); - avl = remove_int(avl, 782); - avl = remove_int(avl, 682); - avl = grpc_avl_add(avl, box(243), box(1361), nullptr); - avl = grpc_avl_add(avl, box(109), box(1362), nullptr); - avl = grpc_avl_add(avl, box(452), box(1363), nullptr); - avl = remove_int(avl, 151); - avl = grpc_avl_add(avl, box(159), box(1365), nullptr); - avl = remove_int(avl, 1023); - avl = grpc_avl_add(avl, box(129), box(1367), nullptr); - avl = grpc_avl_add(avl, box(537), box(1368), nullptr); - avl = remove_int(avl, 321); - avl = grpc_avl_add(avl, box(740), box(1370), nullptr); - avl = remove_int(avl, 45); - avl = remove_int(avl, 136); - avl = grpc_avl_add(avl, box(229), box(1373), nullptr); - avl = remove_int(avl, 772); - avl = grpc_avl_add(avl, box(181), box(1375), nullptr); - avl = remove_int(avl, 175); - avl = grpc_avl_add(avl, box(817), box(1377), nullptr); - avl = remove_int(avl, 956); - avl = grpc_avl_add(avl, box(675), box(1379), nullptr); - avl = grpc_avl_add(avl, box(375), box(1380), nullptr); - avl = remove_int(avl, 384); - avl = grpc_avl_add(avl, box(1016), box(1382), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 697); - avl = remove_int(avl, 554); - avl = remove_int(avl, 590); - avl = remove_int(avl, 1014); - avl = grpc_avl_add(avl, box(890), box(1388), nullptr); - avl = grpc_avl_add(avl, box(293), box(1389), nullptr); - avl = remove_int(avl, 207); - avl = remove_int(avl, 46); - avl = grpc_avl_add(avl, box(899), box(1392), nullptr); - avl = grpc_avl_add(avl, box(666), box(1393), nullptr); - avl = grpc_avl_add(avl, box(85), box(1394), nullptr); - avl = grpc_avl_add(avl, box(914), box(1395), nullptr); - avl = grpc_avl_add(avl, box(128), box(1396), nullptr); - avl = grpc_avl_add(avl, box(835), box(1397), nullptr); - avl = grpc_avl_add(avl, box(787), box(1398), nullptr); - avl = grpc_avl_add(avl, box(649), box(1399), nullptr); - avl = grpc_avl_add(avl, box(723), box(1400), nullptr); - avl = remove_int(avl, 874); - avl = grpc_avl_add(avl, box(778), box(1402), nullptr); - avl = grpc_avl_add(avl, box(1015), box(1403), nullptr); - avl = grpc_avl_add(avl, box(59), box(1404), nullptr); - avl = grpc_avl_add(avl, box(259), box(1405), nullptr); - avl = grpc_avl_add(avl, box(758), box(1406), nullptr); - avl = remove_int(avl, 648); - avl = grpc_avl_add(avl, box(145), box(1408), nullptr); - avl = grpc_avl_add(avl, box(440), box(1409), nullptr); - avl = remove_int(avl, 608); - avl = remove_int(avl, 690); - avl = grpc_avl_add(avl, box(605), box(1412), nullptr); - avl = remove_int(avl, 856); - avl = remove_int(avl, 608); - avl = grpc_avl_add(avl, box(829), box(1415), nullptr); - avl = grpc_avl_add(avl, box(660), box(1416), nullptr); - avl = remove_int(avl, 596); - avl = grpc_avl_add(avl, box(519), box(1418), nullptr); - avl = grpc_avl_add(avl, box(35), box(1419), nullptr); - avl = grpc_avl_add(avl, box(871), box(1420), nullptr); - avl = remove_int(avl, 845); - avl = grpc_avl_add(avl, box(600), box(1422), nullptr); - avl = grpc_avl_add(avl, box(215), box(1423), nullptr); - avl = remove_int(avl, 761); - avl = grpc_avl_add(avl, box(975), box(1425), nullptr); - avl = remove_int(avl, 987); - avl = grpc_avl_add(avl, box(58), box(1427), nullptr); - avl = remove_int(avl, 119); - avl = grpc_avl_add(avl, box(937), box(1429), nullptr); - avl = grpc_avl_add(avl, box(372), box(1430), nullptr); - avl = grpc_avl_add(avl, box(11), box(1431), nullptr); - avl = grpc_avl_add(avl, box(398), box(1432), nullptr); - avl = grpc_avl_add(avl, box(423), box(1433), nullptr); - avl = remove_int(avl, 171); - avl = grpc_avl_add(avl, box(473), box(1435), nullptr); - avl = remove_int(avl, 752); - avl = remove_int(avl, 625); - avl = remove_int(avl, 764); - avl = remove_int(avl, 49); - avl = grpc_avl_add(avl, box(472), box(1440), nullptr); - avl = remove_int(avl, 847); - avl = remove_int(avl, 642); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 795); - avl = remove_int(avl, 465); - avl = grpc_avl_add(avl, box(636), box(1446), nullptr); - avl = remove_int(avl, 152); - avl = grpc_avl_add(avl, box(61), box(1448), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 9); - avl = grpc_avl_add(avl, box(251), box(1451), nullptr); - avl = grpc_avl_add(avl, box(672), box(1452), nullptr); - avl = grpc_avl_add(avl, box(66), box(1453), nullptr); - avl = remove_int(avl, 693); - avl = remove_int(avl, 914); - avl = remove_int(avl, 116); - avl = remove_int(avl, 577); - avl = grpc_avl_add(avl, box(618), box(1458), nullptr); - avl = grpc_avl_add(avl, box(495), box(1459), nullptr); - avl = remove_int(avl, 450); - avl = grpc_avl_add(avl, box(533), box(1461), nullptr); - avl = grpc_avl_add(avl, box(414), box(1462), nullptr); - avl = remove_int(avl, 74); - avl = remove_int(avl, 236); - avl = grpc_avl_add(avl, box(707), box(1465), nullptr); - avl = grpc_avl_add(avl, box(357), box(1466), nullptr); - avl = grpc_avl_add(avl, box(1007), box(1467), nullptr); - avl = grpc_avl_add(avl, box(811), box(1468), nullptr); - avl = grpc_avl_add(avl, box(418), box(1469), nullptr); - avl = grpc_avl_add(avl, box(164), box(1470), nullptr); - avl = grpc_avl_add(avl, box(622), box(1471), nullptr); - avl = remove_int(avl, 22); - avl = remove_int(avl, 14); - avl = remove_int(avl, 732); - avl = remove_int(avl, 7); - avl = remove_int(avl, 447); - avl = grpc_avl_add(avl, box(221), box(1477), nullptr); - avl = grpc_avl_add(avl, box(202), box(1478), nullptr); - avl = grpc_avl_add(avl, box(312), box(1479), nullptr); - avl = remove_int(avl, 274); - avl = grpc_avl_add(avl, box(684), box(1481), nullptr); - avl = grpc_avl_add(avl, box(954), box(1482), nullptr); - avl = grpc_avl_add(avl, box(637), box(1483), nullptr); - avl = remove_int(avl, 716); - avl = grpc_avl_add(avl, box(198), box(1485), nullptr); - avl = remove_int(avl, 340); - avl = remove_int(avl, 137); - avl = remove_int(avl, 995); - avl = remove_int(avl, 1004); - avl = grpc_avl_add(avl, box(661), box(1490), nullptr); - avl = grpc_avl_add(avl, box(862), box(1491), nullptr); - avl = remove_int(avl, 527); - avl = grpc_avl_add(avl, box(945), box(1493), nullptr); - avl = remove_int(avl, 355); - avl = remove_int(avl, 144); - avl = grpc_avl_add(avl, box(229), box(1496), nullptr); - avl = grpc_avl_add(avl, box(237), box(1497), nullptr); - avl = remove_int(avl, 471); - avl = remove_int(avl, 901); - avl = grpc_avl_add(avl, box(905), box(1500), nullptr); - avl = remove_int(avl, 19); - avl = remove_int(avl, 896); - avl = remove_int(avl, 585); - avl = remove_int(avl, 308); - avl = grpc_avl_add(avl, box(547), box(1505), nullptr); - avl = grpc_avl_add(avl, box(552), box(1506), nullptr); - avl = grpc_avl_add(avl, box(30), box(1507), nullptr); - avl = grpc_avl_add(avl, box(445), box(1508), nullptr); - avl = remove_int(avl, 785); - avl = remove_int(avl, 185); - avl = grpc_avl_add(avl, box(405), box(1511), nullptr); - avl = grpc_avl_add(avl, box(733), box(1512), nullptr); - avl = grpc_avl_add(avl, box(573), box(1513), nullptr); - avl = grpc_avl_add(avl, box(492), box(1514), nullptr); - avl = grpc_avl_add(avl, box(343), box(1515), nullptr); - avl = grpc_avl_add(avl, box(527), box(1516), nullptr); - avl = grpc_avl_add(avl, box(596), box(1517), nullptr); - avl = grpc_avl_add(avl, box(519), box(1518), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 722); - avl = grpc_avl_add(avl, box(772), box(1521), nullptr); - avl = remove_int(avl, 152); - avl = remove_int(avl, 305); - avl = grpc_avl_add(avl, box(754), box(1524), nullptr); - avl = grpc_avl_add(avl, box(373), box(1525), nullptr); - avl = remove_int(avl, 995); - avl = grpc_avl_add(avl, box(329), box(1527), nullptr); - avl = remove_int(avl, 397); - avl = grpc_avl_add(avl, box(884), box(1529), nullptr); - avl = remove_int(avl, 329); - avl = remove_int(avl, 240); - avl = grpc_avl_add(avl, box(566), box(1532), nullptr); - avl = grpc_avl_add(avl, box(232), box(1533), nullptr); - avl = remove_int(avl, 993); - avl = grpc_avl_add(avl, box(888), box(1535), nullptr); - avl = remove_int(avl, 242); - avl = grpc_avl_add(avl, box(941), box(1537), nullptr); - avl = remove_int(avl, 415); - avl = grpc_avl_add(avl, box(992), box(1539), nullptr); - avl = remove_int(avl, 289); - avl = grpc_avl_add(avl, box(60), box(1541), nullptr); - avl = grpc_avl_add(avl, box(97), box(1542), nullptr); - avl = remove_int(avl, 965); - avl = remove_int(avl, 267); - avl = remove_int(avl, 360); - avl = grpc_avl_add(avl, box(5), box(1546), nullptr); - avl = remove_int(avl, 429); - avl = grpc_avl_add(avl, box(412), box(1548), nullptr); - avl = remove_int(avl, 632); - avl = remove_int(avl, 113); - avl = grpc_avl_add(avl, box(48), box(1551), nullptr); - avl = grpc_avl_add(avl, box(108), box(1552), nullptr); - avl = grpc_avl_add(avl, box(750), box(1553), nullptr); - avl = remove_int(avl, 188); - avl = grpc_avl_add(avl, box(668), box(1555), nullptr); - avl = remove_int(avl, 37); - avl = remove_int(avl, 737); - avl = grpc_avl_add(avl, box(93), box(1558), nullptr); - avl = grpc_avl_add(avl, box(628), box(1559), nullptr); - avl = grpc_avl_add(avl, box(480), box(1560), nullptr); - avl = remove_int(avl, 958); - avl = remove_int(avl, 565); - avl = remove_int(avl, 32); - avl = remove_int(avl, 1); - avl = remove_int(avl, 335); - avl = grpc_avl_add(avl, box(136), box(1566), nullptr); - avl = grpc_avl_add(avl, box(469), box(1567), nullptr); - avl = remove_int(avl, 349); - avl = grpc_avl_add(avl, box(768), box(1569), nullptr); - avl = grpc_avl_add(avl, box(915), box(1570), nullptr); - avl = remove_int(avl, 1014); - avl = grpc_avl_add(avl, box(117), box(1572), nullptr); - avl = remove_int(avl, 62); - avl = grpc_avl_add(avl, box(382), box(1574), nullptr); - avl = remove_int(avl, 571); - avl = grpc_avl_add(avl, box(655), box(1576), nullptr); - avl = grpc_avl_add(avl, box(323), box(1577), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 151); - avl = grpc_avl_add(avl, box(1019), box(1580), nullptr); - avl = grpc_avl_add(avl, box(984), box(1581), nullptr); - avl = grpc_avl_add(avl, box(870), box(1582), nullptr); - avl = grpc_avl_add(avl, box(376), box(1583), nullptr); - avl = remove_int(avl, 625); - avl = grpc_avl_add(avl, box(733), box(1585), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 444); - avl = grpc_avl_add(avl, box(428), box(1588), nullptr); - avl = grpc_avl_add(avl, box(860), box(1589), nullptr); - avl = grpc_avl_add(avl, box(173), box(1590), nullptr); - avl = remove_int(avl, 649); - avl = remove_int(avl, 913); - avl = remove_int(avl, 1); - avl = remove_int(avl, 304); - avl = grpc_avl_add(avl, box(604), box(1595), nullptr); - avl = grpc_avl_add(avl, box(639), box(1596), nullptr); - avl = remove_int(avl, 431); - avl = grpc_avl_add(avl, box(993), box(1598), nullptr); - avl = remove_int(avl, 681); - avl = remove_int(avl, 927); - avl = grpc_avl_add(avl, box(87), box(1601), nullptr); - avl = grpc_avl_add(avl, box(91), box(1602), nullptr); - avl = remove_int(avl, 61); - avl = remove_int(avl, 14); - avl = remove_int(avl, 305); - avl = remove_int(avl, 304); - avl = remove_int(avl, 1016); - avl = grpc_avl_add(avl, box(903), box(1608), nullptr); - avl = grpc_avl_add(avl, box(951), box(1609), nullptr); - avl = grpc_avl_add(avl, box(146), box(1610), nullptr); - avl = grpc_avl_add(avl, box(482), box(1611), nullptr); - avl = grpc_avl_add(avl, box(71), box(1612), nullptr); - avl = remove_int(avl, 246); - avl = remove_int(avl, 696); - avl = grpc_avl_add(avl, box(636), box(1615), nullptr); - avl = grpc_avl_add(avl, box(295), box(1616), nullptr); - avl = remove_int(avl, 11); - avl = remove_int(avl, 231); - avl = grpc_avl_add(avl, box(905), box(1619), nullptr); - avl = grpc_avl_add(avl, box(993), box(1620), nullptr); - avl = grpc_avl_add(avl, box(433), box(1621), nullptr); - avl = grpc_avl_add(avl, box(117), box(1622), nullptr); - avl = grpc_avl_add(avl, box(467), box(1623), nullptr); - avl = remove_int(avl, 419); - avl = grpc_avl_add(avl, box(179), box(1625), nullptr); - avl = remove_int(avl, 926); - avl = remove_int(avl, 326); - avl = grpc_avl_add(avl, box(551), box(1628), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 476); - avl = remove_int(avl, 823); - avl = grpc_avl_add(avl, box(350), box(1632), nullptr); - avl = grpc_avl_add(avl, box(133), box(1633), nullptr); - avl = remove_int(avl, 906); - avl = grpc_avl_add(avl, box(827), box(1635), nullptr); - avl = grpc_avl_add(avl, box(201), box(1636), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 662); - avl = grpc_avl_add(avl, box(314), box(1639), nullptr); - avl = grpc_avl_add(avl, box(986), box(1640), nullptr); - avl = grpc_avl_add(avl, box(622), box(1641), nullptr); - avl = remove_int(avl, 130); - avl = grpc_avl_add(avl, box(861), box(1643), nullptr); - avl = remove_int(avl, 497); - avl = remove_int(avl, 905); - avl = grpc_avl_add(avl, box(502), box(1646), nullptr); - avl = remove_int(avl, 721); - avl = grpc_avl_add(avl, box(514), box(1648), nullptr); - avl = grpc_avl_add(avl, box(410), box(1649), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 247); - avl = grpc_avl_add(avl, box(450), box(1652), nullptr); - avl = remove_int(avl, 364); - avl = grpc_avl_add(avl, box(963), box(1654), nullptr); - avl = grpc_avl_add(avl, box(146), box(1655), nullptr); - avl = remove_int(avl, 147); - avl = remove_int(avl, 789); - avl = grpc_avl_add(avl, box(693), box(1658), nullptr); - avl = grpc_avl_add(avl, box(959), box(1659), nullptr); - avl = remove_int(avl, 478); - avl = grpc_avl_add(avl, box(116), box(1661), nullptr); - avl = grpc_avl_add(avl, box(520), box(1662), nullptr); - avl = grpc_avl_add(avl, box(809), box(1663), nullptr); - avl = grpc_avl_add(avl, box(667), box(1664), nullptr); - avl = grpc_avl_add(avl, box(406), box(1665), nullptr); - avl = remove_int(avl, 409); - avl = grpc_avl_add(avl, box(558), box(1667), nullptr); - avl = grpc_avl_add(avl, box(0), box(1668), nullptr); - avl = grpc_avl_add(avl, box(948), box(1669), nullptr); - avl = grpc_avl_add(avl, box(576), box(1670), nullptr); - avl = remove_int(avl, 864); - avl = remove_int(avl, 840); - avl = remove_int(avl, 1001); - avl = grpc_avl_add(avl, box(232), box(1674), nullptr); - avl = remove_int(avl, 676); - avl = remove_int(avl, 752); - avl = remove_int(avl, 667); - avl = remove_int(avl, 605); - avl = grpc_avl_add(avl, box(258), box(1679), nullptr); - avl = grpc_avl_add(avl, box(648), box(1680), nullptr); - avl = grpc_avl_add(avl, box(761), box(1681), nullptr); - avl = remove_int(avl, 293); - avl = remove_int(avl, 893); - avl = grpc_avl_add(avl, box(194), box(1684), nullptr); - avl = remove_int(avl, 233); - avl = grpc_avl_add(avl, box(888), box(1686), nullptr); - avl = remove_int(avl, 470); - avl = remove_int(avl, 703); - avl = remove_int(avl, 190); - avl = remove_int(avl, 359); - avl = grpc_avl_add(avl, box(621), box(1691), nullptr); - avl = remove_int(avl, 634); - avl = remove_int(avl, 335); - avl = grpc_avl_add(avl, box(718), box(1694), nullptr); - avl = grpc_avl_add(avl, box(463), box(1695), nullptr); - avl = grpc_avl_add(avl, box(233), box(1696), nullptr); - avl = remove_int(avl, 376); - avl = remove_int(avl, 496); - avl = remove_int(avl, 819); - avl = remove_int(avl, 38); - avl = remove_int(avl, 436); - avl = remove_int(avl, 102); - avl = grpc_avl_add(avl, box(607), box(1703), nullptr); - avl = remove_int(avl, 329); - avl = grpc_avl_add(avl, box(716), box(1705), nullptr); - avl = remove_int(avl, 639); - avl = remove_int(avl, 775); - avl = remove_int(avl, 578); - avl = remove_int(avl, 464); - avl = remove_int(avl, 679); - avl = remove_int(avl, 615); - avl = remove_int(avl, 104); - avl = grpc_avl_add(avl, box(414), box(1713), nullptr); - avl = grpc_avl_add(avl, box(212), box(1714), nullptr); - avl = grpc_avl_add(avl, box(266), box(1715), nullptr); - avl = grpc_avl_add(avl, box(238), box(1716), nullptr); - avl = remove_int(avl, 153); - avl = grpc_avl_add(avl, box(585), box(1718), nullptr); - avl = remove_int(avl, 121); - avl = grpc_avl_add(avl, box(534), box(1720), nullptr); - avl = remove_int(avl, 579); - avl = grpc_avl_add(avl, box(127), box(1722), nullptr); - avl = grpc_avl_add(avl, box(399), box(1723), nullptr); - avl = remove_int(avl, 417); - avl = grpc_avl_add(avl, box(978), box(1725), nullptr); - avl = grpc_avl_add(avl, box(768), box(1726), nullptr); - avl = remove_int(avl, 985); - avl = grpc_avl_add(avl, box(536), box(1728), nullptr); - avl = grpc_avl_add(avl, box(449), box(1729), nullptr); - avl = grpc_avl_add(avl, box(586), box(1730), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 394); - avl = remove_int(avl, 141); - avl = grpc_avl_add(avl, box(889), box(1734), nullptr); - avl = grpc_avl_add(avl, box(871), box(1735), nullptr); - avl = grpc_avl_add(avl, box(76), box(1736), nullptr); - avl = grpc_avl_add(avl, box(549), box(1737), nullptr); - avl = grpc_avl_add(avl, box(757), box(1738), nullptr); - avl = remove_int(avl, 908); - avl = grpc_avl_add(avl, box(789), box(1740), nullptr); - avl = remove_int(avl, 224); - avl = grpc_avl_add(avl, box(407), box(1742), nullptr); - avl = grpc_avl_add(avl, box(381), box(1743), nullptr); - avl = grpc_avl_add(avl, box(561), box(1744), nullptr); - avl = grpc_avl_add(avl, box(667), box(1745), nullptr); - avl = grpc_avl_add(avl, box(522), box(1746), nullptr); - avl = grpc_avl_add(avl, box(948), box(1747), nullptr); - avl = remove_int(avl, 770); - avl = grpc_avl_add(avl, box(872), box(1749), nullptr); - avl = grpc_avl_add(avl, box(327), box(1750), nullptr); - avl = remove_int(avl, 10); - avl = grpc_avl_add(avl, box(122), box(1752), nullptr); - avl = remove_int(avl, 606); - avl = grpc_avl_add(avl, box(485), box(1754), nullptr); - avl = remove_int(avl, 6); - avl = grpc_avl_add(avl, box(329), box(1756), nullptr); - avl = grpc_avl_add(avl, box(783), box(1757), nullptr); - avl = remove_int(avl, 416); - avl = grpc_avl_add(avl, box(656), box(1759), nullptr); - avl = grpc_avl_add(avl, box(971), box(1760), nullptr); - avl = grpc_avl_add(avl, box(77), box(1761), nullptr); - avl = grpc_avl_add(avl, box(942), box(1762), nullptr); - avl = remove_int(avl, 361); - avl = grpc_avl_add(avl, box(66), box(1764), nullptr); - avl = grpc_avl_add(avl, box(299), box(1765), nullptr); - avl = grpc_avl_add(avl, box(929), box(1766), nullptr); - avl = grpc_avl_add(avl, box(797), box(1767), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 907); - avl = grpc_avl_add(avl, box(870), box(1770), nullptr); - avl = remove_int(avl, 580); - avl = remove_int(avl, 120); - avl = grpc_avl_add(avl, box(913), box(1773), nullptr); - avl = remove_int(avl, 480); - avl = grpc_avl_add(avl, box(489), box(1775), nullptr); - avl = remove_int(avl, 845); - avl = grpc_avl_add(avl, box(896), box(1777), nullptr); - avl = remove_int(avl, 567); - avl = remove_int(avl, 427); - avl = grpc_avl_add(avl, box(443), box(1780), nullptr); - avl = grpc_avl_add(avl, box(3), box(1781), nullptr); - avl = remove_int(avl, 12); - avl = grpc_avl_add(avl, box(376), box(1783), nullptr); - avl = grpc_avl_add(avl, box(155), box(1784), nullptr); - avl = grpc_avl_add(avl, box(188), box(1785), nullptr); - avl = grpc_avl_add(avl, box(149), box(1786), nullptr); - avl = grpc_avl_add(avl, box(178), box(1787), nullptr); - avl = remove_int(avl, 84); - avl = grpc_avl_add(avl, box(805), box(1789), nullptr); - avl = grpc_avl_add(avl, box(612), box(1790), nullptr); - avl = remove_int(avl, 991); - avl = grpc_avl_add(avl, box(837), box(1792), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 72); - avl = grpc_avl_add(avl, box(1014), box(1795), nullptr); - avl = remove_int(avl, 303); - avl = grpc_avl_add(avl, box(865), box(1797), nullptr); - avl = grpc_avl_add(avl, box(793), box(1798), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 477); - avl = grpc_avl_add(avl, box(950), box(1801), nullptr); - avl = grpc_avl_add(avl, box(105), box(1802), nullptr); - avl = grpc_avl_add(avl, box(895), box(1803), nullptr); - avl = grpc_avl_add(avl, box(171), box(1804), nullptr); - avl = grpc_avl_add(avl, box(753), box(1805), nullptr); - avl = grpc_avl_add(avl, box(946), box(1806), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 559); - avl = remove_int(avl, 116); - avl = grpc_avl_add(avl, box(968), box(1810), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 99); - avl = grpc_avl_add(avl, box(563), box(1813), nullptr); - avl = remove_int(avl, 182); - avl = grpc_avl_add(avl, box(816), box(1815), nullptr); - avl = remove_int(avl, 73); - avl = remove_int(avl, 261); - avl = grpc_avl_add(avl, box(847), box(1818), nullptr); - avl = grpc_avl_add(avl, box(368), box(1819), nullptr); - avl = grpc_avl_add(avl, box(808), box(1820), nullptr); - avl = grpc_avl_add(avl, box(779), box(1821), nullptr); - avl = remove_int(avl, 818); - avl = grpc_avl_add(avl, box(466), box(1823), nullptr); - avl = remove_int(avl, 316); - avl = grpc_avl_add(avl, box(986), box(1825), nullptr); - avl = grpc_avl_add(avl, box(688), box(1826), nullptr); - avl = grpc_avl_add(avl, box(509), box(1827), nullptr); - avl = grpc_avl_add(avl, box(51), box(1828), nullptr); - avl = remove_int(avl, 655); - avl = remove_int(avl, 785); - avl = remove_int(avl, 893); - avl = grpc_avl_add(avl, box(167), box(1832), nullptr); - avl = remove_int(avl, 13); - avl = remove_int(avl, 263); - avl = grpc_avl_add(avl, box(1009), box(1835), nullptr); - avl = remove_int(avl, 480); - avl = remove_int(avl, 778); - avl = remove_int(avl, 713); - avl = remove_int(avl, 628); - avl = grpc_avl_add(avl, box(803), box(1840), nullptr); - avl = remove_int(avl, 267); - avl = grpc_avl_add(avl, box(676), box(1842), nullptr); - avl = grpc_avl_add(avl, box(231), box(1843), nullptr); - avl = grpc_avl_add(avl, box(824), box(1844), nullptr); - avl = remove_int(avl, 961); - avl = grpc_avl_add(avl, box(311), box(1846), nullptr); - avl = grpc_avl_add(avl, box(420), box(1847), nullptr); - avl = grpc_avl_add(avl, box(960), box(1848), nullptr); - avl = grpc_avl_add(avl, box(468), box(1849), nullptr); - avl = grpc_avl_add(avl, box(815), box(1850), nullptr); - avl = remove_int(avl, 247); - avl = remove_int(avl, 194); - avl = grpc_avl_add(avl, box(546), box(1853), nullptr); - avl = remove_int(avl, 222); - avl = remove_int(avl, 914); - avl = remove_int(avl, 741); - avl = grpc_avl_add(avl, box(470), box(1857), nullptr); - avl = grpc_avl_add(avl, box(933), box(1858), nullptr); - avl = grpc_avl_add(avl, box(97), box(1859), nullptr); - avl = remove_int(avl, 564); - avl = remove_int(avl, 295); - avl = grpc_avl_add(avl, box(864), box(1862), nullptr); - avl = remove_int(avl, 329); - avl = grpc_avl_add(avl, box(124), box(1864), nullptr); - avl = grpc_avl_add(avl, box(1000), box(1865), nullptr); - avl = grpc_avl_add(avl, box(228), box(1866), nullptr); - avl = grpc_avl_add(avl, box(187), box(1867), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 306); - avl = remove_int(avl, 884); - avl = grpc_avl_add(avl, box(449), box(1871), nullptr); - avl = grpc_avl_add(avl, box(353), box(1872), nullptr); - avl = grpc_avl_add(avl, box(994), box(1873), nullptr); - avl = grpc_avl_add(avl, box(596), box(1874), nullptr); - avl = grpc_avl_add(avl, box(996), box(1875), nullptr); - avl = grpc_avl_add(avl, box(101), box(1876), nullptr); - avl = grpc_avl_add(avl, box(1012), box(1877), nullptr); - avl = grpc_avl_add(avl, box(982), box(1878), nullptr); - avl = grpc_avl_add(avl, box(742), box(1879), nullptr); - avl = remove_int(avl, 92); - avl = remove_int(avl, 1022); - avl = grpc_avl_add(avl, box(941), box(1882), nullptr); - avl = remove_int(avl, 742); - avl = remove_int(avl, 919); - avl = grpc_avl_add(avl, box(588), box(1885), nullptr); - avl = remove_int(avl, 221); - avl = grpc_avl_add(avl, box(356), box(1887), nullptr); - avl = grpc_avl_add(avl, box(932), box(1888), nullptr); - avl = remove_int(avl, 837); - avl = grpc_avl_add(avl, box(394), box(1890), nullptr); - avl = grpc_avl_add(avl, box(642), box(1891), nullptr); - avl = grpc_avl_add(avl, box(52), box(1892), nullptr); - avl = grpc_avl_add(avl, box(437), box(1893), nullptr); - avl = grpc_avl_add(avl, box(948), box(1894), nullptr); - avl = grpc_avl_add(avl, box(93), box(1895), nullptr); - avl = remove_int(avl, 873); - avl = remove_int(avl, 336); - avl = remove_int(avl, 277); - avl = remove_int(avl, 932); - avl = grpc_avl_add(avl, box(80), box(1900), nullptr); - avl = grpc_avl_add(avl, box(952), box(1901), nullptr); - avl = grpc_avl_add(avl, box(510), box(1902), nullptr); - avl = remove_int(avl, 876); - avl = remove_int(avl, 612); - avl = grpc_avl_add(avl, box(923), box(1905), nullptr); - avl = grpc_avl_add(avl, box(475), box(1906), nullptr); - avl = remove_int(avl, 478); - avl = remove_int(avl, 148); - avl = grpc_avl_add(avl, box(538), box(1909), nullptr); - avl = remove_int(avl, 47); - avl = grpc_avl_add(avl, box(89), box(1911), nullptr); - avl = remove_int(avl, 723); - avl = grpc_avl_add(avl, box(687), box(1913), nullptr); - avl = grpc_avl_add(avl, box(480), box(1914), nullptr); - avl = grpc_avl_add(avl, box(149), box(1915), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 862); - avl = remove_int(avl, 363); - avl = grpc_avl_add(avl, box(996), box(1919), nullptr); - avl = remove_int(avl, 380); - avl = grpc_avl_add(avl, box(957), box(1921), nullptr); - avl = remove_int(avl, 413); - avl = grpc_avl_add(avl, box(360), box(1923), nullptr); - avl = grpc_avl_add(avl, box(304), box(1924), nullptr); - avl = grpc_avl_add(avl, box(634), box(1925), nullptr); - avl = grpc_avl_add(avl, box(506), box(1926), nullptr); - avl = remove_int(avl, 248); - avl = grpc_avl_add(avl, box(124), box(1928), nullptr); - avl = grpc_avl_add(avl, box(181), box(1929), nullptr); - avl = remove_int(avl, 507); - avl = grpc_avl_add(avl, box(141), box(1931), nullptr); - avl = remove_int(avl, 409); - avl = remove_int(avl, 129); - avl = remove_int(avl, 694); - avl = remove_int(avl, 723); - avl = grpc_avl_add(avl, box(998), box(1936), nullptr); - avl = grpc_avl_add(avl, box(906), box(1937), nullptr); - avl = grpc_avl_add(avl, box(44), box(1938), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 117); - avl = grpc_avl_add(avl, box(700), box(1941), nullptr); - avl = grpc_avl_add(avl, box(258), box(1942), nullptr); - avl = remove_int(avl, 828); - avl = grpc_avl_add(avl, box(860), box(1944), nullptr); - avl = grpc_avl_add(avl, box(987), box(1945), nullptr); - avl = grpc_avl_add(avl, box(316), box(1946), nullptr); - avl = grpc_avl_add(avl, box(919), box(1947), nullptr); - avl = remove_int(avl, 84); - avl = grpc_avl_add(avl, box(473), box(1949), nullptr); - avl = remove_int(avl, 127); - avl = remove_int(avl, 829); - avl = remove_int(avl, 829); - avl = grpc_avl_add(avl, box(488), box(1953), nullptr); - avl = grpc_avl_add(avl, box(954), box(1954), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 972); - avl = remove_int(avl, 670); - avl = grpc_avl_add(avl, box(822), box(1958), nullptr); - avl = remove_int(avl, 589); - avl = remove_int(avl, 459); - avl = grpc_avl_add(avl, box(1003), box(1961), nullptr); - avl = grpc_avl_add(avl, box(657), box(1962), nullptr); - avl = grpc_avl_add(avl, box(477), box(1963), nullptr); - avl = grpc_avl_add(avl, box(923), box(1964), nullptr); - avl = remove_int(avl, 496); - avl = remove_int(avl, 99); - avl = grpc_avl_add(avl, box(127), box(1967), nullptr); - avl = grpc_avl_add(avl, box(1013), box(1968), nullptr); - avl = grpc_avl_add(avl, box(778), box(1969), nullptr); - avl = remove_int(avl, 5); - avl = remove_int(avl, 990); - avl = remove_int(avl, 850); - avl = remove_int(avl, 160); - avl = remove_int(avl, 86); - avl = grpc_avl_add(avl, box(283), box(1975), nullptr); - avl = remove_int(avl, 278); - avl = remove_int(avl, 297); - avl = remove_int(avl, 137); - avl = remove_int(avl, 653); - avl = grpc_avl_add(avl, box(702), box(1980), nullptr); - avl = remove_int(avl, 63); - avl = remove_int(avl, 427); - avl = remove_int(avl, 706); - avl = remove_int(avl, 806); - avl = grpc_avl_add(avl, box(335), box(1985), nullptr); - avl = grpc_avl_add(avl, box(412), box(1986), nullptr); - avl = remove_int(avl, 766); - avl = remove_int(avl, 937); - avl = remove_int(avl, 886); - avl = remove_int(avl, 652); - avl = grpc_avl_add(avl, box(545), box(1991), nullptr); - avl = grpc_avl_add(avl, box(408), box(1992), nullptr); - avl = grpc_avl_add(avl, box(841), box(1993), nullptr); - avl = remove_int(avl, 593); - avl = grpc_avl_add(avl, box(582), box(1995), nullptr); - avl = grpc_avl_add(avl, box(597), box(1996), nullptr); - avl = remove_int(avl, 49); - avl = remove_int(avl, 835); - avl = grpc_avl_add(avl, box(417), box(1999), nullptr); - avl = grpc_avl_add(avl, box(191), box(2000), nullptr); - avl = remove_int(avl, 406); - avl = grpc_avl_add(avl, box(30), box(2002), nullptr); - avl = remove_int(avl, 841); - avl = remove_int(avl, 50); - avl = grpc_avl_add(avl, box(967), box(2005), nullptr); - avl = grpc_avl_add(avl, box(849), box(2006), nullptr); - avl = remove_int(avl, 608); - avl = grpc_avl_add(avl, box(306), box(2008), nullptr); - avl = remove_int(avl, 779); - avl = grpc_avl_add(avl, box(897), box(2010), nullptr); - avl = grpc_avl_add(avl, box(147), box(2011), nullptr); - avl = remove_int(avl, 982); - avl = grpc_avl_add(avl, box(470), box(2013), nullptr); - avl = remove_int(avl, 951); - avl = grpc_avl_add(avl, box(388), box(2015), nullptr); - avl = remove_int(avl, 616); - avl = remove_int(avl, 721); - avl = remove_int(avl, 942); - avl = remove_int(avl, 589); - avl = grpc_avl_add(avl, box(218), box(2020), nullptr); - avl = remove_int(avl, 671); - avl = grpc_avl_add(avl, box(1020), box(2022), nullptr); - avl = remove_int(avl, 277); - avl = grpc_avl_add(avl, box(681), box(2024), nullptr); - avl = grpc_avl_add(avl, box(179), box(2025), nullptr); - avl = grpc_avl_add(avl, box(370), box(2026), nullptr); - avl = grpc_avl_add(avl, box(0), box(2027), nullptr); - avl = remove_int(avl, 523); - avl = grpc_avl_add(avl, box(99), box(2029), nullptr); - avl = grpc_avl_add(avl, box(334), box(2030), nullptr); - avl = grpc_avl_add(avl, box(569), box(2031), nullptr); - avl = grpc_avl_add(avl, box(257), box(2032), nullptr); - avl = remove_int(avl, 572); - avl = grpc_avl_add(avl, box(805), box(2034), nullptr); - avl = grpc_avl_add(avl, box(143), box(2035), nullptr); - avl = grpc_avl_add(avl, box(670), box(2036), nullptr); - avl = remove_int(avl, 42); - avl = grpc_avl_add(avl, box(46), box(2038), nullptr); - avl = remove_int(avl, 970); - avl = grpc_avl_add(avl, box(353), box(2040), nullptr); - avl = remove_int(avl, 258); - avl = grpc_avl_add(avl, box(451), box(2042), nullptr); - avl = grpc_avl_add(avl, box(28), box(2043), nullptr); - avl = grpc_avl_add(avl, box(729), box(2044), nullptr); - avl = grpc_avl_add(avl, box(401), box(2045), nullptr); - avl = grpc_avl_add(avl, box(614), box(2046), nullptr); - avl = remove_int(avl, 990); - avl = remove_int(avl, 212); - avl = remove_int(avl, 22); - avl = remove_int(avl, 677); - avl = grpc_avl_add(avl, box(1016), box(2051), nullptr); - avl = grpc_avl_add(avl, box(980), box(2052), nullptr); - avl = grpc_avl_add(avl, box(990), box(2053), nullptr); - avl = grpc_avl_add(avl, box(355), box(2054), nullptr); - avl = remove_int(avl, 730); - avl = remove_int(avl, 37); - avl = grpc_avl_add(avl, box(407), box(2057), nullptr); - avl = grpc_avl_add(avl, box(222), box(2058), nullptr); - avl = grpc_avl_add(avl, box(439), box(2059), nullptr); - avl = grpc_avl_add(avl, box(563), box(2060), nullptr); - avl = remove_int(avl, 992); - avl = remove_int(avl, 786); - avl = grpc_avl_add(avl, box(1), box(2063), nullptr); - avl = grpc_avl_add(avl, box(473), box(2064), nullptr); - avl = grpc_avl_add(avl, box(992), box(2065), nullptr); - avl = remove_int(avl, 190); - avl = remove_int(avl, 450); - avl = remove_int(avl, 1020); - avl = remove_int(avl, 149); - avl = grpc_avl_add(avl, box(329), box(2070), nullptr); - avl = grpc_avl_add(avl, box(35), box(2071), nullptr); - avl = remove_int(avl, 843); - avl = grpc_avl_add(avl, box(855), box(2073), nullptr); - avl = remove_int(avl, 878); - avl = grpc_avl_add(avl, box(993), box(2075), nullptr); - avl = grpc_avl_add(avl, box(87), box(2076), nullptr); - avl = grpc_avl_add(avl, box(572), box(2077), nullptr); - avl = remove_int(avl, 896); - avl = grpc_avl_add(avl, box(849), box(2079), nullptr); - avl = remove_int(avl, 597); - avl = grpc_avl_add(avl, box(472), box(2081), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 934); - avl = remove_int(avl, 314); - avl = grpc_avl_add(avl, box(101), box(2085), nullptr); - avl = remove_int(avl, 938); - avl = remove_int(avl, 1010); - avl = grpc_avl_add(avl, box(579), box(2088), nullptr); - avl = remove_int(avl, 798); - avl = remove_int(avl, 88); - avl = grpc_avl_add(avl, box(851), box(2091), nullptr); - avl = remove_int(avl, 705); - avl = grpc_avl_add(avl, box(26), box(2093), nullptr); - avl = remove_int(avl, 973); - avl = grpc_avl_add(avl, box(923), box(2095), nullptr); - avl = remove_int(avl, 668); - avl = grpc_avl_add(avl, box(310), box(2097), nullptr); - avl = grpc_avl_add(avl, box(269), box(2098), nullptr); - avl = remove_int(avl, 173); - avl = grpc_avl_add(avl, box(279), box(2100), nullptr); - avl = remove_int(avl, 203); - avl = grpc_avl_add(avl, box(411), box(2102), nullptr); - avl = remove_int(avl, 950); - avl = grpc_avl_add(avl, box(6), box(2104), nullptr); - avl = remove_int(avl, 400); - avl = remove_int(avl, 468); - avl = remove_int(avl, 271); - avl = grpc_avl_add(avl, box(627), box(2108), nullptr); - avl = remove_int(avl, 727); - avl = remove_int(avl, 148); - avl = remove_int(avl, 98); - avl = remove_int(avl, 997); - avl = remove_int(avl, 215); - avl = remove_int(avl, 628); - avl = remove_int(avl, 826); - avl = remove_int(avl, 664); - avl = grpc_avl_add(avl, box(76), box(2117), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 18); - avl = grpc_avl_add(avl, box(727), box(2120), nullptr); - avl = remove_int(avl, 295); - avl = grpc_avl_add(avl, box(645), box(2122), nullptr); - avl = remove_int(avl, 321); - avl = remove_int(avl, 863); - avl = grpc_avl_add(avl, box(824), box(2125), nullptr); - avl = grpc_avl_add(avl, box(651), box(2126), nullptr); - avl = grpc_avl_add(avl, box(804), box(2127), nullptr); - avl = remove_int(avl, 307); - avl = grpc_avl_add(avl, box(867), box(2129), nullptr); - avl = remove_int(avl, 384); - avl = grpc_avl_add(avl, box(819), box(2131), nullptr); - avl = remove_int(avl, 674); - avl = grpc_avl_add(avl, box(76), box(2133), nullptr); - avl = remove_int(avl, 898); - avl = grpc_avl_add(avl, box(45), box(2135), nullptr); - avl = grpc_avl_add(avl, box(512), box(2136), nullptr); - avl = remove_int(avl, 773); - avl = remove_int(avl, 907); - avl = remove_int(avl, 382); - avl = remove_int(avl, 95); - avl = remove_int(avl, 734); - avl = remove_int(avl, 81); - avl = grpc_avl_add(avl, box(348), box(2143), nullptr); - avl = remove_int(avl, 509); - avl = remove_int(avl, 301); - avl = grpc_avl_add(avl, box(861), box(2146), nullptr); - avl = grpc_avl_add(avl, box(918), box(2147), nullptr); - avl = remove_int(avl, 992); - avl = grpc_avl_add(avl, box(356), box(2149), nullptr); - avl = remove_int(avl, 64); - avl = remove_int(avl, 444); - avl = remove_int(avl, 741); - avl = grpc_avl_add(avl, box(710), box(2153), nullptr); - avl = grpc_avl_add(avl, box(264), box(2154), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 250); - avl = grpc_avl_add(avl, box(82), box(2157), nullptr); - avl = grpc_avl_add(avl, box(571), box(2158), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 622); - avl = grpc_avl_add(avl, box(950), box(2161), nullptr); - avl = grpc_avl_add(avl, box(94), box(2162), nullptr); - avl = remove_int(avl, 970); - avl = grpc_avl_add(avl, box(815), box(2164), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 703); - avl = grpc_avl_add(avl, box(432), box(2167), nullptr); - avl = remove_int(avl, 544); - avl = grpc_avl_add(avl, box(21), box(2169), nullptr); - avl = grpc_avl_add(avl, box(186), box(2170), nullptr); - avl = remove_int(avl, 143); - avl = grpc_avl_add(avl, box(425), box(2172), nullptr); - avl = remove_int(avl, 769); - avl = grpc_avl_add(avl, box(656), box(2174), nullptr); - avl = remove_int(avl, 29); - avl = grpc_avl_add(avl, box(464), box(2176), nullptr); - avl = remove_int(avl, 713); - avl = grpc_avl_add(avl, box(800), box(2178), nullptr); - avl = remove_int(avl, 621); - avl = grpc_avl_add(avl, box(962), box(2180), nullptr); - avl = remove_int(avl, 448); - avl = grpc_avl_add(avl, box(878), box(2182), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 999); - avl = grpc_avl_add(avl, box(182), box(2185), nullptr); - avl = grpc_avl_add(avl, box(429), box(2186), nullptr); - avl = grpc_avl_add(avl, box(598), box(2187), nullptr); - avl = remove_int(avl, 551); - avl = grpc_avl_add(avl, box(827), box(2189), nullptr); - avl = grpc_avl_add(avl, box(809), box(2190), nullptr); - avl = remove_int(avl, 438); - avl = remove_int(avl, 811); - avl = grpc_avl_add(avl, box(808), box(2193), nullptr); - avl = grpc_avl_add(avl, box(788), box(2194), nullptr); - avl = remove_int(avl, 156); - avl = grpc_avl_add(avl, box(933), box(2196), nullptr); - avl = grpc_avl_add(avl, box(344), box(2197), nullptr); - avl = remove_int(avl, 460); - avl = grpc_avl_add(avl, box(161), box(2199), nullptr); - avl = grpc_avl_add(avl, box(444), box(2200), nullptr); - avl = remove_int(avl, 597); - avl = remove_int(avl, 668); - avl = grpc_avl_add(avl, box(703), box(2203), nullptr); - avl = remove_int(avl, 515); - avl = grpc_avl_add(avl, box(380), box(2205), nullptr); - avl = grpc_avl_add(avl, box(338), box(2206), nullptr); - avl = remove_int(avl, 550); - avl = remove_int(avl, 946); - avl = remove_int(avl, 714); - avl = remove_int(avl, 739); - avl = grpc_avl_add(avl, box(413), box(2211), nullptr); - avl = remove_int(avl, 450); - avl = grpc_avl_add(avl, box(411), box(2213), nullptr); - avl = grpc_avl_add(avl, box(117), box(2214), nullptr); - avl = grpc_avl_add(avl, box(322), box(2215), nullptr); - avl = grpc_avl_add(avl, box(915), box(2216), nullptr); - avl = grpc_avl_add(avl, box(410), box(2217), nullptr); - avl = grpc_avl_add(avl, box(66), box(2218), nullptr); - avl = remove_int(avl, 756); - avl = remove_int(avl, 596); - avl = grpc_avl_add(avl, box(882), box(2221), nullptr); - avl = grpc_avl_add(avl, box(930), box(2222), nullptr); - avl = grpc_avl_add(avl, box(36), box(2223), nullptr); - avl = remove_int(avl, 742); - avl = grpc_avl_add(avl, box(539), box(2225), nullptr); - avl = grpc_avl_add(avl, box(596), box(2226), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 686); - avl = remove_int(avl, 933); - avl = remove_int(avl, 42); - avl = remove_int(avl, 340); - avl = grpc_avl_add(avl, box(126), box(2232), nullptr); - avl = grpc_avl_add(avl, box(493), box(2233), nullptr); - avl = grpc_avl_add(avl, box(839), box(2234), nullptr); - avl = remove_int(avl, 774); - avl = grpc_avl_add(avl, box(337), box(2236), nullptr); - avl = remove_int(avl, 322); - avl = grpc_avl_add(avl, box(16), box(2238), nullptr); - avl = remove_int(avl, 73); - avl = remove_int(avl, 85); - avl = remove_int(avl, 191); - avl = remove_int(avl, 541); - avl = grpc_avl_add(avl, box(704), box(2243), nullptr); - avl = remove_int(avl, 767); - avl = remove_int(avl, 1006); - avl = remove_int(avl, 844); - avl = remove_int(avl, 742); - avl = grpc_avl_add(avl, box(48), box(2248), nullptr); - avl = grpc_avl_add(avl, box(138), box(2249), nullptr); - avl = grpc_avl_add(avl, box(437), box(2250), nullptr); - avl = grpc_avl_add(avl, box(275), box(2251), nullptr); - avl = remove_int(avl, 520); - avl = grpc_avl_add(avl, box(1019), box(2253), nullptr); - avl = remove_int(avl, 955); - avl = grpc_avl_add(avl, box(270), box(2255), nullptr); - avl = remove_int(avl, 680); - avl = remove_int(avl, 698); - avl = grpc_avl_add(avl, box(735), box(2258), nullptr); - avl = grpc_avl_add(avl, box(400), box(2259), nullptr); - avl = remove_int(avl, 991); - avl = grpc_avl_add(avl, box(263), box(2261), nullptr); - avl = remove_int(avl, 704); - avl = grpc_avl_add(avl, box(757), box(2263), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 616); - avl = remove_int(avl, 784); - avl = grpc_avl_add(avl, box(382), box(2267), nullptr); - avl = grpc_avl_add(avl, box(464), box(2268), nullptr); - avl = grpc_avl_add(avl, box(817), box(2269), nullptr); - avl = remove_int(avl, 445); - avl = grpc_avl_add(avl, box(412), box(2271), nullptr); - avl = remove_int(avl, 525); - avl = grpc_avl_add(avl, box(299), box(2273), nullptr); - avl = grpc_avl_add(avl, box(464), box(2274), nullptr); - avl = grpc_avl_add(avl, box(715), box(2275), nullptr); - avl = remove_int(avl, 58); - avl = remove_int(avl, 218); - avl = grpc_avl_add(avl, box(961), box(2278), nullptr); - avl = grpc_avl_add(avl, box(491), box(2279), nullptr); - avl = remove_int(avl, 846); - avl = grpc_avl_add(avl, box(762), box(2281), nullptr); - avl = remove_int(avl, 974); - avl = remove_int(avl, 887); - avl = grpc_avl_add(avl, box(498), box(2284), nullptr); - avl = remove_int(avl, 810); - avl = remove_int(avl, 743); - avl = remove_int(avl, 22); - avl = remove_int(avl, 284); - avl = grpc_avl_add(avl, box(482), box(2289), nullptr); - avl = grpc_avl_add(avl, box(1021), box(2290), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 128); - avl = grpc_avl_add(avl, box(819), box(2293), nullptr); - avl = grpc_avl_add(avl, box(324), box(2294), nullptr); - avl = remove_int(avl, 196); - avl = remove_int(avl, 370); - avl = remove_int(avl, 753); - avl = remove_int(avl, 56); - avl = remove_int(avl, 735); - avl = grpc_avl_add(avl, box(272), box(2300), nullptr); - avl = grpc_avl_add(avl, box(474), box(2301), nullptr); - avl = grpc_avl_add(avl, box(719), box(2302), nullptr); - avl = grpc_avl_add(avl, box(236), box(2303), nullptr); - avl = remove_int(avl, 818); - avl = grpc_avl_add(avl, box(727), box(2305), nullptr); - avl = remove_int(avl, 892); - avl = remove_int(avl, 871); - avl = remove_int(avl, 231); - avl = grpc_avl_add(avl, box(62), box(2309), nullptr); - avl = grpc_avl_add(avl, box(953), box(2310), nullptr); - avl = remove_int(avl, 701); - avl = grpc_avl_add(avl, box(193), box(2312), nullptr); - avl = remove_int(avl, 619); - avl = remove_int(avl, 22); - avl = remove_int(avl, 804); - avl = remove_int(avl, 851); - avl = grpc_avl_add(avl, box(286), box(2317), nullptr); - avl = grpc_avl_add(avl, box(751), box(2318), nullptr); - avl = remove_int(avl, 525); - avl = grpc_avl_add(avl, box(217), box(2320), nullptr); - avl = remove_int(avl, 336); - avl = grpc_avl_add(avl, box(86), box(2322), nullptr); - avl = grpc_avl_add(avl, box(81), box(2323), nullptr); - avl = grpc_avl_add(avl, box(850), box(2324), nullptr); - avl = remove_int(avl, 872); - avl = grpc_avl_add(avl, box(402), box(2326), nullptr); - avl = grpc_avl_add(avl, box(54), box(2327), nullptr); - avl = grpc_avl_add(avl, box(980), box(2328), nullptr); - avl = grpc_avl_add(avl, box(845), box(2329), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 273); - avl = remove_int(avl, 879); - avl = grpc_avl_add(avl, box(354), box(2333), nullptr); - avl = grpc_avl_add(avl, box(58), box(2334), nullptr); - avl = grpc_avl_add(avl, box(127), box(2335), nullptr); - avl = remove_int(avl, 84); - avl = grpc_avl_add(avl, box(360), box(2337), nullptr); - avl = remove_int(avl, 648); - avl = remove_int(avl, 488); - avl = remove_int(avl, 585); - avl = remove_int(avl, 230); - avl = grpc_avl_add(avl, box(887), box(2342), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 958); - avl = grpc_avl_add(avl, box(822), box(2345), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 747); - avl = grpc_avl_add(avl, box(631), box(2348), nullptr); - avl = grpc_avl_add(avl, box(442), box(2349), nullptr); - avl = remove_int(avl, 957); - avl = remove_int(avl, 964); - avl = grpc_avl_add(avl, box(10), box(2352), nullptr); - avl = remove_int(avl, 189); - avl = grpc_avl_add(avl, box(742), box(2354), nullptr); - avl = remove_int(avl, 108); - avl = grpc_avl_add(avl, box(1014), box(2356), nullptr); - avl = remove_int(avl, 266); - avl = remove_int(avl, 623); - avl = remove_int(avl, 697); - avl = grpc_avl_add(avl, box(180), box(2360), nullptr); - avl = remove_int(avl, 472); - avl = grpc_avl_add(avl, box(567), box(2362), nullptr); - avl = remove_int(avl, 1020); - avl = remove_int(avl, 273); - avl = grpc_avl_add(avl, box(864), box(2365), nullptr); - avl = grpc_avl_add(avl, box(1009), box(2366), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 81); - avl = grpc_avl_add(avl, box(653), box(2369), nullptr); - avl = remove_int(avl, 67); - avl = remove_int(avl, 102); - avl = remove_int(avl, 76); - avl = remove_int(avl, 935); - avl = remove_int(avl, 169); - avl = remove_int(avl, 232); - avl = remove_int(avl, 79); - avl = grpc_avl_add(avl, box(509), box(2377), nullptr); - avl = remove_int(avl, 900); - avl = remove_int(avl, 822); - avl = remove_int(avl, 945); - avl = remove_int(avl, 356); - avl = grpc_avl_add(avl, box(443), box(2382), nullptr); - avl = grpc_avl_add(avl, box(925), box(2383), nullptr); - avl = remove_int(avl, 994); - avl = remove_int(avl, 324); - avl = grpc_avl_add(avl, box(291), box(2386), nullptr); - avl = remove_int(avl, 94); - avl = remove_int(avl, 795); - avl = remove_int(avl, 42); - avl = grpc_avl_add(avl, box(613), box(2390), nullptr); - avl = remove_int(avl, 289); - avl = grpc_avl_add(avl, box(980), box(2392), nullptr); - avl = remove_int(avl, 316); - avl = grpc_avl_add(avl, box(281), box(2394), nullptr); - avl = grpc_avl_add(avl, box(1006), box(2395), nullptr); - avl = remove_int(avl, 776); - avl = grpc_avl_add(avl, box(108), box(2397), nullptr); - avl = grpc_avl_add(avl, box(918), box(2398), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 563); - avl = grpc_avl_add(avl, box(925), box(2401), nullptr); - avl = remove_int(avl, 448); - avl = remove_int(avl, 198); - avl = remove_int(avl, 1); - avl = grpc_avl_add(avl, box(160), box(2405), nullptr); - avl = remove_int(avl, 515); - avl = grpc_avl_add(avl, box(284), box(2407), nullptr); - avl = grpc_avl_add(avl, box(225), box(2408), nullptr); - avl = remove_int(avl, 304); - avl = grpc_avl_add(avl, box(714), box(2410), nullptr); - avl = grpc_avl_add(avl, box(708), box(2411), nullptr); - avl = grpc_avl_add(avl, box(624), box(2412), nullptr); - avl = remove_int(avl, 662); - avl = remove_int(avl, 825); - avl = remove_int(avl, 383); - avl = remove_int(avl, 381); - avl = grpc_avl_add(avl, box(194), box(2417), nullptr); - avl = remove_int(avl, 280); - avl = remove_int(avl, 25); - avl = remove_int(avl, 633); - avl = grpc_avl_add(avl, box(897), box(2421), nullptr); - avl = remove_int(avl, 636); - avl = remove_int(avl, 596); - avl = remove_int(avl, 757); - avl = remove_int(avl, 343); - avl = remove_int(avl, 162); - avl = remove_int(avl, 913); - avl = remove_int(avl, 843); - avl = remove_int(avl, 280); - avl = remove_int(avl, 911); - avl = grpc_avl_add(avl, box(1008), box(2431), nullptr); - avl = remove_int(avl, 948); - avl = remove_int(avl, 74); - avl = remove_int(avl, 571); - avl = grpc_avl_add(avl, box(486), box(2435), nullptr); - avl = grpc_avl_add(avl, box(285), box(2436), nullptr); - avl = remove_int(avl, 304); - avl = remove_int(avl, 516); - avl = grpc_avl_add(avl, box(758), box(2439), nullptr); - avl = grpc_avl_add(avl, box(776), box(2440), nullptr); - avl = remove_int(avl, 696); - avl = grpc_avl_add(avl, box(104), box(2442), nullptr); - avl = grpc_avl_add(avl, box(700), box(2443), nullptr); - avl = grpc_avl_add(avl, box(114), box(2444), nullptr); - avl = grpc_avl_add(avl, box(567), box(2445), nullptr); - avl = remove_int(avl, 620); - avl = grpc_avl_add(avl, box(270), box(2447), nullptr); - avl = remove_int(avl, 730); - avl = grpc_avl_add(avl, box(749), box(2449), nullptr); - avl = grpc_avl_add(avl, box(443), box(2450), nullptr); - avl = remove_int(avl, 457); - avl = grpc_avl_add(avl, box(571), box(2452), nullptr); - avl = grpc_avl_add(avl, box(626), box(2453), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 313); - - grpc_avl_unref(avl, nullptr); -} - static void test_stress(int amount_of_stress) { int added[1024]; int i, j; @@ -3653,8 +294,6 @@ int main(int argc, char* argv[]) { test_replace(); test_remove(); test_badcase1(); - test_badcase2(); - test_badcase3(); test_stress(10); return 0; diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 81c4353129..da419f00cf 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -122,6 +122,7 @@ grpc_cc_test( language = "C++", deps = [ "//:grpc", + "//test/core/util:gpr_test_util", ], external_deps = [ "gtest", diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc index e34aa2e676..1c8d0775ab 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -60,11 +60,11 @@ static void my_resolve_address(const char* addr, const char* default_port, static grpc_address_resolver_vtable test_resolver = {my_resolve_address, nullptr}; -static grpc_ares_request* my_dns_lookup_ares( +static grpc_ares_request* my_dns_lookup_ares_locked( const char* dns_server, const char* addr, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** lb_addrs, bool check_grpclb, - char** service_config_json) { + grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { gpr_mu_lock(&g_mu); GPR_ASSERT(0 == strcmp("test", addr)); grpc_error* error = GRPC_ERROR_NONE; @@ -147,7 +147,7 @@ int main(int argc, char** argv) { gpr_mu_init(&g_mu); g_combiner = grpc_combiner_create(); grpc_set_resolver_impl(&test_resolver); - grpc_dns_lookup_ares = my_dns_lookup_ares; + grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked; grpc_channel_args* result = (grpc_channel_args*)1; { diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 521fc3107e..b1f3a1c08a 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -33,10 +33,11 @@ static grpc_address_resolver_vtable* default_resolve_address; static grpc_combiner* g_combiner; -grpc_ares_request* (*g_default_dns_lookup_ares)( +grpc_ares_request* (*g_default_dns_lookup_ares_locked)( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json); + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner); // Counter incremented by test_resolve_address_impl indicating the number of // times a system-level resolution has happened. @@ -72,13 +73,14 @@ static grpc_error* test_blocking_resolve_address_impl( static grpc_address_resolver_vtable test_resolver = { test_resolve_address_impl, test_blocking_resolve_address_impl}; -grpc_ares_request* test_dns_lookup_ares( +grpc_ares_request* test_dns_lookup_ares_locked( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) { - grpc_ares_request* result = g_default_dns_lookup_ares( + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { + grpc_ares_request* result = g_default_dns_lookup_ares_locked( dns_server, name, default_port, g_iomgr_args.pollset_set, on_done, addrs, - check_grpclb, service_config_json); + check_grpclb, service_config_json, combiner); ++g_resolution_count; return result; } @@ -308,8 +310,8 @@ int main(int argc, char** argv) { g_combiner = grpc_combiner_create(); - g_default_dns_lookup_ares = grpc_dns_lookup_ares; - grpc_dns_lookup_ares = test_dns_lookup_ares; + g_default_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked; + grpc_dns_lookup_ares_locked = test_dns_lookup_ares_locked; default_resolve_address = grpc_resolve_address_impl; grpc_set_resolver_impl(&test_resolver); diff --git a/test/core/end2end/end2end_nosec_tests.cc b/test/core/end2end/end2end_nosec_tests.cc index 5ee0bb83fd..061b23b5d6 100644 --- a/test/core/end2end/end2end_nosec_tests.cc +++ b/test/core/end2end/end2end_nosec_tests.cc @@ -102,6 +102,8 @@ extern void negative_deadline(grpc_end2end_test_config config); extern void negative_deadline_pre_init(void); extern void network_status_change(grpc_end2end_test_config config); extern void network_status_change_pre_init(void); +extern void no_error_on_hotpath(grpc_end2end_test_config config); +extern void no_error_on_hotpath_pre_init(void); extern void no_logging(grpc_end2end_test_config config); extern void no_logging_pre_init(void); extern void no_op(grpc_end2end_test_config config); @@ -225,6 +227,7 @@ void grpc_end2end_tests_pre_init(void) { max_message_length_pre_init(); negative_deadline_pre_init(); network_status_change_pre_init(); + no_error_on_hotpath_pre_init(); no_logging_pre_init(); no_op_pre_init(); payload_pre_init(); @@ -311,6 +314,7 @@ void grpc_end2end_tests(int argc, char **argv, max_message_length(config); negative_deadline(config); network_status_change(config); + no_error_on_hotpath(config); no_logging(config); no_op(config); payload(config); @@ -500,6 +504,10 @@ void grpc_end2end_tests(int argc, char **argv, network_status_change(config); continue; } + if (0 == strcmp("no_error_on_hotpath", argv[i])) { + no_error_on_hotpath(config); + continue; + } if (0 == strcmp("no_logging", argv[i])) { no_logging(config); continue; diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc index ca5c18bcc2..7ae475cdef 100644 --- a/test/core/end2end/end2end_tests.cc +++ b/test/core/end2end/end2end_tests.cc @@ -104,6 +104,8 @@ extern void negative_deadline(grpc_end2end_test_config config); extern void negative_deadline_pre_init(void); extern void network_status_change(grpc_end2end_test_config config); extern void network_status_change_pre_init(void); +extern void no_error_on_hotpath(grpc_end2end_test_config config); +extern void no_error_on_hotpath_pre_init(void); extern void no_logging(grpc_end2end_test_config config); extern void no_logging_pre_init(void); extern void no_op(grpc_end2end_test_config config); @@ -228,6 +230,7 @@ void grpc_end2end_tests_pre_init(void) { max_message_length_pre_init(); negative_deadline_pre_init(); network_status_change_pre_init(); + no_error_on_hotpath_pre_init(); no_logging_pre_init(); no_op_pre_init(); payload_pre_init(); @@ -315,6 +318,7 @@ void grpc_end2end_tests(int argc, char **argv, max_message_length(config); negative_deadline(config); network_status_change(config); + no_error_on_hotpath(config); no_logging(config); no_op(config); payload(config); @@ -508,6 +512,10 @@ void grpc_end2end_tests(int argc, char **argv, network_status_change(config); continue; } + if (0 == strcmp("no_error_on_hotpath", argv[i])) { + no_error_on_hotpath(config); + continue; + } if (0 == strcmp("no_logging", argv[i])) { no_logging(config); continue; diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index 0af8a29a15..c2ac209cf9 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -69,9 +69,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, char* proxy_uri; /* If testing for proxy auth, add credentials to proxy uri */ - const grpc_arg* proxy_auth_arg = - grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS); - const char* proxy_auth_str = grpc_channel_arg_get_string(proxy_auth_arg); + const char* proxy_auth_str = + grpc_channel_args_get_string(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS); if (proxy_auth_str == nullptr) { gpr_asprintf(&proxy_uri, "http://%s", grpc_end2end_http_proxy_get_proxy_name(ffd->proxy)); diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index f02fa9d998..5caddee09e 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -411,9 +411,8 @@ static void on_read_request_done(void* arg, grpc_error* error) { return; } // If proxy auth is being used, check if the header is present and as expected - const grpc_arg* proxy_auth_arg = grpc_channel_args_find( + char* proxy_auth_str = grpc_channel_args_get_string( conn->proxy->channel_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS); - char* proxy_auth_str = grpc_channel_arg_get_string(proxy_auth_arg); if (proxy_auth_str != nullptr) { bool client_authenticated = false; for (size_t i = 0; i < conn->http_request.hdr_count; i++) { diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index ba9c04fd0e..d0d82ea43b 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -374,13 +374,11 @@ void my_resolve_address(const char* addr, const char* default_port, static grpc_address_resolver_vtable fuzzer_resolver = {my_resolve_address, nullptr}; -grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr, - const char* default_port, - grpc_pollset_set* interested_parties, - grpc_closure* on_done, - grpc_lb_addresses** lb_addrs, - bool check_grpclb, - char** service_config_json) { +grpc_ares_request* my_dns_lookup_ares_locked( + const char* dns_server, const char* addr, const char* default_port, + grpc_pollset_set* interested_parties, grpc_closure* on_done, + grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r))); r->addr = gpr_strdup(addr); r->on_done = on_done; @@ -706,7 +704,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_executor_set_threading(false); } grpc_set_resolver_impl(&fuzzer_resolver); - grpc_dns_lookup_ares = my_dns_lookup_ares; + grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked; GPR_ASSERT(g_channel == nullptr); GPR_ASSERT(g_server == nullptr); diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index 53f4ab0d52..04dc2a8785 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -139,6 +139,7 @@ END2END_TESTS = { 'max_message_length': default_test_options._replace(cpu_cost=LOWCPU), 'negative_deadline': default_test_options, 'network_status_change': default_test_options._replace(cpu_cost=LOWCPU), + 'no_error_on_hotpath': default_test_options._replace(proxyable=False), 'no_logging': default_test_options._replace(traceable=False), 'no_op': default_test_options, 'payload': default_test_options, diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index 94bc092b59..67769a8cb1 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -135,6 +135,7 @@ END2END_TESTS = { 'max_message_length': test_options(), 'negative_deadline': test_options(), 'network_status_change': test_options(), + 'no_error_on_hotpath': test_options(proxyable=False), 'no_logging': test_options(traceable=False), 'no_op': test_options(), 'payload': test_options(), diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index 0188698f17..8904c3d325 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -44,11 +44,11 @@ static void* tag(intptr_t i) { return (void*)i; } static gpr_mu g_mu; static int g_resolve_port = -1; -static grpc_ares_request* (*iomgr_dns_lookup_ares)( +static grpc_ares_request* (*iomgr_dns_lookup_ares_locked)( const char* dns_server, const char* addr, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb, - char** service_config_json); + char** service_config_json, grpc_combiner* combiner); static void set_resolve_port(int port) { gpr_mu_lock(&g_mu); @@ -98,15 +98,15 @@ static grpc_error* my_blocking_resolve_address( static grpc_address_resolver_vtable test_resolver = { my_resolve_address, my_blocking_resolve_address}; -static grpc_ares_request* my_dns_lookup_ares( +static grpc_ares_request* my_dns_lookup_ares_locked( const char* dns_server, const char* addr, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, - grpc_lb_addresses** lb_addrs, bool check_grpclb, - char** service_config_json) { + grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json, + grpc_combiner* combiner) { if (0 != strcmp(addr, "test")) { - return iomgr_dns_lookup_ares(dns_server, addr, default_port, - interested_parties, on_done, lb_addrs, - check_grpclb, service_config_json); + return iomgr_dns_lookup_ares_locked( + dns_server, addr, default_port, interested_parties, on_done, lb_addrs, + check_grpclb, service_config_json, combiner); } grpc_error* error = GRPC_ERROR_NONE; @@ -142,8 +142,8 @@ int main(int argc, char** argv) { grpc_init(); default_resolver = grpc_resolve_address_impl; grpc_set_resolver_impl(&test_resolver); - iomgr_dns_lookup_ares = grpc_dns_lookup_ares; - grpc_dns_lookup_ares = my_dns_lookup_ares; + iomgr_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked; + grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked; int was_cancelled1; int was_cancelled2; diff --git a/test/core/end2end/tests/no_error_on_hotpath.cc b/test/core/end2end/tests/no_error_on_hotpath.cc new file mode 100644 index 0000000000..7afadf7d3a --- /dev/null +++ b/test/core/end2end/tests/no_error_on_hotpath.cc @@ -0,0 +1,246 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test/core/end2end/end2end_tests.h" + +#include <stdio.h> +#include <string.h> + +#include <grpc/byte_buffer.h> +#include <grpc/grpc.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/time.h> +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/error.h" +#include "test/core/end2end/cq_verifier.h" + +static void* tag(intptr_t t) { return (void*)t; } + +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { + grpc_end2end_test_fixture f; + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_server(&f, server_args); + config.init_client(&f, client_args); + return f; +} + +static gpr_timespec n_seconds_from_now(int n) { + return grpc_timeout_seconds_to_deadline(n); +} + +static gpr_timespec five_seconds_from_now(void) { + return n_seconds_from_now(5); +} + +static void drain_cq(grpc_completion_queue* cq) { + grpc_event ev; + do { + ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); +} + +static void shutdown_server(grpc_end2end_test_fixture* f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + nullptr) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); + f->server = nullptr; +} + +static void shutdown_client(grpc_end2end_test_fixture* f) { + if (!f->client) return; + grpc_channel_destroy(f->client); + f->client = nullptr; +} + +static void end_test(grpc_end2end_test_fixture* f) { + shutdown_server(f); + shutdown_client(f); + + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); +} + +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); + grpc_op ops[6]; + grpc_op* op; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_call_details call_details; + grpc_status_code status; + grpc_call_error error; + grpc_slice details; + int was_cancelled = 2; + char* peer; + + gpr_timespec deadline = five_seconds_from_now(); + c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), nullptr, + deadline, nullptr); + GPR_ASSERT(c); + + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != nullptr); + gpr_free(peer); + + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1), + nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + cq_verify(cqv); + + peer = grpc_call_get_peer(s); + GPR_ASSERT(peer != nullptr); + gpr_free(peer); + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != nullptr); + gpr_free(peer); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_OK; + op->data.send_status_from_server.status_details = nullptr; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102), + nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + CQ_EXPECT_COMPLETION(cqv, tag(1), 1); + cq_verify(cqv); + + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(GRPC_SLICE_LENGTH(details) == 0); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); + GPR_ASSERT(0 == call_details.flags); + GPR_ASSERT(was_cancelled == 0); + + grpc_slice_unref(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + grpc_call_unref(c); + grpc_call_unref(s); + + cq_verifier_destroy(cqv); +} + +static void test_no_error_on_hotpath_one_request( + grpc_end2end_test_config config) { + grpc_end2end_test_fixture f; + + f = begin_test(config, "test_invoke_simple_request_with_no_error_logging", + nullptr, nullptr); + // First RPC is not considered the hotpath, since there are lots of things to + // set up. + simple_request_body(config, f); + grpc_disable_error_creation(); + simple_request_body(config, f); + grpc_enable_error_creation(); + end_test(&f); + config.tear_down_data(&f); +} + +static void test_no_error_on_hotpath_10_requests( + grpc_end2end_test_config config) { + int i; + grpc_end2end_test_fixture f = begin_test( + config, "test_no_error_on_hotpath_in_one_request", nullptr, nullptr); + // First RPC is not considered the hotpath, since there are lots of things to + // set up. + simple_request_body(config, f); + grpc_disable_error_creation(); + for (i = 0; i < 10; i++) { + simple_request_body(config, f); + } + grpc_enable_error_creation(); + end_test(&f); + config.tear_down_data(&f); +} + +void no_error_on_hotpath(grpc_end2end_test_config config) { + test_no_error_on_hotpath_one_request(config); + test_no_error_on_hotpath_10_requests(config); +} + +void no_error_on_hotpath_pre_init(void) {} diff --git a/test/core/end2end/tests/retry_server_pushback_delay.cc b/test/core/end2end/tests/retry_server_pushback_delay.cc index f6a979613d..221b416828 100644 --- a/test/core/end2end/tests/retry_server_pushback_delay.cc +++ b/test/core/end2end/tests/retry_server_pushback_delay.cc @@ -249,7 +249,7 @@ static void test_retry_server_pushback_delay(grpc_end2end_test_config config) { retry_delay.tv_sec, retry_delay.tv_nsec); GPR_ASSERT(retry_delay.tv_sec >= 1); if (retry_delay.tv_sec == 1) { - GPR_ASSERT(retry_delay.tv_nsec >= 900000000); + GPR_ASSERT(retry_delay.tv_nsec >= 800000000); } peer = grpc_call_get_peer(s); diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc index 111414ea3e..3e7c906591 100644 --- a/test/core/gpr/arena_test.cc +++ b/test/core/gpr/arena_test.cc @@ -71,7 +71,7 @@ static void test(const char* name, size_t init_size, const size_t* allocs, static const size_t allocs_##name[] = {__VA_ARGS__}; \ test(#name, init_size, allocs_##name, GPR_ARRAY_SIZE(allocs_##name)) -#define CONCURRENT_TEST_THREADS 100 +#define CONCURRENT_TEST_THREADS 10 size_t concurrent_test_iterations() { if (sizeof(void*) < 8) return 1000; diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index 349a06d578..bbf0815e6f 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -227,6 +227,7 @@ grpc_cc_test( "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], + tags = ["manual"], # TODO(adelez): Remove once this works on Foundry. ) grpc_cc_test( diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc index c3ba6d7c14..28c9dd408c 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.cc +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -66,7 +66,7 @@ static void test_fd_init(test_fd* tfds, int* fds, int num_fds) { for (i = 0; i < num_fds; i++) { tfds[i].inner_fd = fds[i]; - tfds[i].fd = grpc_fd_create(fds[i], "test_fd"); + tfds[i].fd = grpc_fd_create(fds[i], "test_fd", false); } } @@ -79,8 +79,7 @@ static void test_fd_cleanup(test_fd* tfds, int num_fds) { GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup")); grpc_core::ExecCtx::Get()->Flush(); - grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */, - "test_fd_cleanup"); + grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, "test_fd_cleanup"); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(release_fd == tfds[i].inner_fd); @@ -267,7 +266,7 @@ static void test_threading(void) { grpc_wakeup_fd fd; GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&fd))); shared.wakeup_fd = &fd; - shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup"); + shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup", false); shared.wakeups = 0; { grpc_core::ExecCtx exec_ctx; @@ -287,8 +286,7 @@ static void test_threading(void) { { grpc_core::ExecCtx exec_ctx; grpc_fd_shutdown(shared.wakeup_desc, GRPC_ERROR_CANCELLED); - grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr, - false /* already_closed */, "done"); + grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr, "done"); grpc_pollset_shutdown(shared.pollset, GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset, grpc_schedule_on_exec_ctx)); diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc index b81c73b2c0..4ea2389bbd 100644 --- a/test/core/iomgr/fd_posix_test.cc +++ b/test/core/iomgr/fd_posix_test.cc @@ -115,7 +115,7 @@ static void session_shutdown_cb(void* arg, /*session */ bool success) { session* se = static_cast<session*>(arg); server* sv = se->sv; - grpc_fd_orphan(se->em_fd, nullptr, nullptr, false /* already_closed */, "a"); + grpc_fd_orphan(se->em_fd, nullptr, nullptr, "a"); gpr_free(se); /* Start to shutdown listen fd. */ grpc_fd_shutdown(sv->em_fd, @@ -171,7 +171,7 @@ static void session_read_cb(void* arg, /*session */ static void listen_shutdown_cb(void* arg /*server */, int success) { server* sv = static_cast<server*>(arg); - grpc_fd_orphan(sv->em_fd, nullptr, nullptr, false /* already_closed */, "b"); + grpc_fd_orphan(sv->em_fd, nullptr, nullptr, "b"); gpr_mu_lock(g_mu); sv->done = 1; @@ -204,7 +204,7 @@ static void listen_cb(void* arg, /*=sv_arg*/ fcntl(fd, F_SETFL, flags | O_NONBLOCK); se = static_cast<session*>(gpr_malloc(sizeof(*se))); se->sv = sv; - se->em_fd = grpc_fd_create(fd, "listener"); + se->em_fd = grpc_fd_create(fd, "listener", false); grpc_pollset_add_fd(g_pollset, se->em_fd); GRPC_CLOSURE_INIT(&se->session_read_closure, session_read_cb, se, grpc_schedule_on_exec_ctx); @@ -233,7 +233,7 @@ static int server_start(server* sv) { port = ntohs(sin.sin_port); GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0); - sv->em_fd = grpc_fd_create(fd, "server"); + sv->em_fd = grpc_fd_create(fd, "server", false); grpc_pollset_add_fd(g_pollset, sv->em_fd); /* Register to be interested in reading from listen_fd. */ GRPC_CLOSURE_INIT(&sv->listen_closure, listen_cb, sv, @@ -289,7 +289,7 @@ static void client_init(client* cl) { /* Called when a client upload session is ready to shutdown. */ static void client_session_shutdown_cb(void* arg /*client */, int success) { client* cl = static_cast<client*>(arg); - grpc_fd_orphan(cl->em_fd, nullptr, nullptr, false /* already_closed */, "c"); + grpc_fd_orphan(cl->em_fd, nullptr, nullptr, "c"); cl->done = 1; GPR_ASSERT( GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr))); @@ -353,7 +353,7 @@ static void client_start(client* cl, int port) { } } - cl->em_fd = grpc_fd_create(fd, "client"); + cl->em_fd = grpc_fd_create(fd, "client", false); grpc_pollset_add_fd(g_pollset, cl->em_fd); client_session_write(cl, GRPC_ERROR_NONE); @@ -454,7 +454,7 @@ static void test_grpc_fd_change(void) { flags = fcntl(sv[1], F_GETFL, 0); GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0); - em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change"); + em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change", false); grpc_pollset_add_fd(g_pollset, em_fd); /* Register the first callback, then make its FD readable */ @@ -502,7 +502,7 @@ static void test_grpc_fd_change(void) { GPR_ASSERT(b.cb_that_ran == second_read_callback); gpr_mu_unlock(g_mu); - grpc_fd_orphan(em_fd, nullptr, nullptr, false /* already_closed */, "d"); + grpc_fd_orphan(em_fd, nullptr, nullptr, "d"); destroy_change_data(&a); destroy_change_data(&b); diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm new file mode 100644 index 0000000000..414b6c78c0 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm @@ -0,0 +1,201 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import <XCTest/XCTest.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM + +#include <netinet/in.h> + +#include <grpc/impl/codegen/sync.h> +#include <grpc/support/sync.h> + +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/resolve_address.h" +#include "src/core/lib/iomgr/tcp_client.h" +#include "test/core/util/test_config.h" + +// static int g_connections_complete = 0; +static gpr_mu g_mu; +static int g_connections_complete = 0; +static grpc_endpoint* g_connecting = nullptr; + +static void finish_connection() { + gpr_mu_lock(&g_mu); + g_connections_complete++; + gpr_mu_unlock(&g_mu); +} + +static void must_succeed(void* arg, grpc_error* error) { + GPR_ASSERT(g_connecting != nullptr); + GPR_ASSERT(error == GRPC_ERROR_NONE); + grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called")); + grpc_endpoint_destroy(g_connecting); + g_connecting = nullptr; + finish_connection(); +} + +static void must_fail(void* arg, grpc_error* error) { + GPR_ASSERT(g_connecting == nullptr); + GPR_ASSERT(error != GRPC_ERROR_NONE); + const char* error_str = grpc_error_string(error); + NSLog(@"%s", error_str); + finish_connection(); +} + +@interface CFStreamClientTests : XCTestCase + +@end + +@implementation CFStreamClientTests + ++ (void)setUp { + grpc_init(); + gpr_mu_init(&g_mu); +} + ++ (void)tearDown { + grpc_shutdown(); +} + +- (void)testSucceeds { + grpc_resolved_address resolved_addr; + struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr); + int svr_fd; + int r; + int connections_complete_before; + grpc_closure done; + grpc_core::ExecCtx exec_ctx; + + gpr_log(GPR_DEBUG, "test_succeeds"); + + memset(&resolved_addr, 0, sizeof(resolved_addr)); + resolved_addr.len = sizeof(struct sockaddr_in); + addr->sin_family = AF_INET; + + /* create a dummy server */ + svr_fd = socket(AF_INET, SOCK_STREAM, 0); + GPR_ASSERT(svr_fd >= 0); + GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len)); + GPR_ASSERT(0 == listen(svr_fd, 1)); + + gpr_mu_lock(&g_mu); + connections_complete_before = g_connections_complete; + gpr_mu_unlock(&g_mu); + + /* connect to it */ + GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0); + GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx); + grpc_tcp_client_connect(&done, &g_connecting, nullptr, nullptr, &resolved_addr, + GRPC_MILLIS_INF_FUTURE); + + /* await the connection */ + do { + resolved_addr.len = sizeof(addr); + r = accept(svr_fd, reinterpret_cast<struct sockaddr*>(addr), + reinterpret_cast<socklen_t*>(&resolved_addr.len)); + } while (r == -1 && errno == EINTR); + GPR_ASSERT(r >= 0); + close(r); + + grpc_core::ExecCtx::Get()->Flush(); + + /* wait for the connection callback to finish */ + gpr_mu_lock(&g_mu); + NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:5]; + while (connections_complete_before == g_connections_complete) { + gpr_mu_unlock(&g_mu); + [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline]; + gpr_mu_lock(&g_mu); + } + XCTAssertGreaterThan(g_connections_complete, connections_complete_before); + + gpr_mu_unlock(&g_mu); +} + +- (void)testFails { + grpc_core::ExecCtx exec_ctx; + + grpc_resolved_address resolved_addr; + struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr); + int connections_complete_before; + grpc_closure done; + int svr_fd; + + gpr_log(GPR_DEBUG, "test_fails"); + + memset(&resolved_addr, 0, sizeof(resolved_addr)); + resolved_addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_in)); + addr->sin_family = AF_INET; + + svr_fd = socket(AF_INET, SOCK_STREAM, 0); + GPR_ASSERT(svr_fd >= 0); + GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len)); + GPR_ASSERT(0 == listen(svr_fd, 1)); + GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0); + close(svr_fd); + + gpr_mu_lock(&g_mu); + connections_complete_before = g_connections_complete; + gpr_mu_unlock(&g_mu); + + /* connect to a broken address */ + GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx); + grpc_tcp_client_connect(&done, &g_connecting, nullptr, nullptr, &resolved_addr, + GRPC_MILLIS_INF_FUTURE); + + grpc_core::ExecCtx::Get()->Flush(); + + /* wait for the connection callback to finish */ + gpr_mu_lock(&g_mu); + NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:5]; + while (g_connections_complete == connections_complete_before) { + gpr_mu_unlock(&g_mu); + [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline]; + gpr_mu_lock(&g_mu); + } + + XCTAssertGreaterThan(g_connections_complete, connections_complete_before); + + gpr_mu_unlock(&g_mu); +} + +@end + +#else // GRPC_CFSTREAM + +// Dummy test suite +@interface CFStreamClientTests : XCTestCase + +@end + +@implementation CFStreamClientTests + +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +@end + +#endif // GRPC_CFSTREAM diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm new file mode 100644 index 0000000000..fbc34c74d6 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm @@ -0,0 +1,344 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import <XCTest/XCTest.h> + +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_CFSTREAM + +#include <netinet/in.h> + +#include <grpc/impl/codegen/sync.h> +#include <grpc/support/sync.h> + +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/resolve_address.h" +#include "src/core/lib/iomgr/tcp_client.h" +#include "test/core/util/test_config.h" + +static const int kConnectTimeout = 5; +static const int kWriteTimeout = 5; +static const int kReadTimeout = 5; + +static const int kBufferSize = 10000; + +static const int kRunLoopTimeout = 1; + +static void set_atm(void *arg, grpc_error *error) { + gpr_atm *p = static_cast<gpr_atm *>(arg); + gpr_atm_full_cas(p, -1, reinterpret_cast<gpr_atm>(error)); +} + +static void init_event_closure(grpc_closure *closure, gpr_atm *atm) { + *atm = -1; + GRPC_CLOSURE_INIT(closure, set_atm, static_cast<void *>(atm), grpc_schedule_on_exec_ctx); +} + +static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const char *buffer, + size_t buffer_len) { + if (slices->length != buffer_len) { + return false; + } + + for (int i = 0; i < slices->count; i++) { + grpc_slice slice = slices->slices[i]; + if (0 != memcmp(buffer, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice))) { + return false; + } + buffer += GRPC_SLICE_LENGTH(slice); + } + + return true; +} + +@interface CFStreamEndpointTests : XCTestCase + +@end + +@implementation CFStreamEndpointTests { + grpc_endpoint *ep_; + int svr_fd_; +} + +- (BOOL)waitForEvent:(gpr_atm *)event timeout:(int)timeout { + grpc_core::ExecCtx::Get()->Flush(); + + NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:kConnectTimeout]; + while (gpr_atm_acq_load(event) == -1 && [deadline timeIntervalSinceNow] > 0) { + NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:kRunLoopTimeout]; + [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline]; + } + + return (gpr_atm_acq_load(event) != -1); +} + ++ (void)setUp { + grpc_init(); +} + ++ (void)tearDown { + grpc_shutdown(); +} + +- (void)setUp { + self.continueAfterFailure = NO; + + // Set up CFStream connection before testing the endpoint + + grpc_core::ExecCtx exec_ctx; + + grpc_resolved_address resolved_addr; + struct sockaddr_in *addr = reinterpret_cast<struct sockaddr_in *>(resolved_addr.addr); + int svr_fd; + int r; + gpr_atm connected = -1; + grpc_closure done; + + gpr_log(GPR_DEBUG, "test_succeeds"); + + memset(&resolved_addr, 0, sizeof(resolved_addr)); + resolved_addr.len = sizeof(struct sockaddr_in); + addr->sin_family = AF_INET; + + /* create a dummy server */ + svr_fd = socket(AF_INET, SOCK_STREAM, 0); + XCTAssertGreaterThanOrEqual(svr_fd, 0); + XCTAssertEqual(bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len), 0); + XCTAssertEqual(listen(svr_fd, 1), 0); + + /* connect to it */ + XCTAssertEqual(getsockname(svr_fd, (struct sockaddr *)addr, (socklen_t *)&resolved_addr.len), 0); + init_event_closure(&done, &connected); + grpc_tcp_client_connect(&done, &ep_, nullptr, nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE); + + /* await the connection */ + do { + resolved_addr.len = sizeof(addr); + r = accept(svr_fd, reinterpret_cast<struct sockaddr *>(addr), + reinterpret_cast<socklen_t *>(&resolved_addr.len)); + } while (r == -1 && errno == EINTR); + XCTAssertGreaterThanOrEqual(r, 0); + svr_fd_ = r; + + /* wait for the connection callback to finish */ + XCTAssertEqual([self waitForEvent:&connected timeout:kConnectTimeout], YES); + XCTAssertEqual(reinterpret_cast<grpc_error *>(connected), GRPC_ERROR_NONE); +} + +- (void)tearDown { + grpc_core::ExecCtx exec_ctx; + close(svr_fd_); + grpc_endpoint_destroy(ep_); +} + +- (void)testReadWrite { + grpc_core::ExecCtx exec_ctx; + + gpr_atm read; + grpc_closure read_done; + grpc_slice_buffer read_slices; + grpc_slice_buffer read_one_slice; + gpr_atm write; + grpc_closure write_done; + grpc_slice_buffer write_slices; + + grpc_slice slice; + char write_buffer[kBufferSize]; + char read_buffer[kBufferSize]; + size_t recv_size = 0; + + grpc_slice_buffer_init(&write_slices); + slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize); + grpc_slice_buffer_add(&write_slices, slice); + init_event_closure(&write_done, &write); + grpc_endpoint_write(ep_, &write_slices, &write_done); + + XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES); + XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE); + + while (recv_size < kBufferSize) { + ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0); + XCTAssertGreaterThanOrEqual(size, 0); + recv_size += size; + } + + XCTAssertEqual(recv_size, kBufferSize); + XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0); + ssize_t send_size = send(svr_fd_, read_buffer, kBufferSize, 0); + XCTAssertGreaterThanOrEqual(send_size, 0); + + grpc_slice_buffer_init(&read_slices); + grpc_slice_buffer_init(&read_one_slice); + while (read_slices.length < kBufferSize) { + init_event_closure(&read_done, &read); + grpc_endpoint_read(ep_, &read_one_slice, &read_done); + XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES); + XCTAssertEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE); + grpc_slice_buffer_move_into(&read_one_slice, &read_slices); + XCTAssertLessThanOrEqual(read_slices.length, kBufferSize); + } + XCTAssertTrue(compare_slice_buffer_with_buffer(&read_slices, read_buffer, kBufferSize)); + + grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE); + grpc_slice_buffer_reset_and_unref(&read_slices); + grpc_slice_buffer_reset_and_unref(&write_slices); + grpc_slice_buffer_reset_and_unref(&read_one_slice); +} + +- (void)testShutdownBeforeRead { + grpc_core::ExecCtx exec_ctx; + + gpr_atm read; + grpc_closure read_done; + grpc_slice_buffer read_slices; + gpr_atm write; + grpc_closure write_done; + grpc_slice_buffer write_slices; + + grpc_slice slice; + char write_buffer[kBufferSize]; + char read_buffer[kBufferSize]; + size_t recv_size = 0; + + grpc_slice_buffer_init(&read_slices); + init_event_closure(&read_done, &read); + grpc_endpoint_read(ep_, &read_slices, &read_done); + + grpc_slice_buffer_init(&write_slices); + slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize); + grpc_slice_buffer_add(&write_slices, slice); + init_event_closure(&write_done, &write); + grpc_endpoint_write(ep_, &write_slices, &write_done); + + XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES); + XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE); + + while (recv_size < kBufferSize) { + ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0); + XCTAssertGreaterThanOrEqual(size, 0); + recv_size += size; + } + + XCTAssertEqual(recv_size, kBufferSize); + XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0); + + XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], NO); + + grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE); + + grpc_core::ExecCtx::Get()->Flush(); + XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES); + XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE); + + grpc_slice_buffer_reset_and_unref(&read_slices); + grpc_slice_buffer_reset_and_unref(&write_slices); +} + +- (void)testRemoteClosed { + grpc_core::ExecCtx exec_ctx; + + gpr_atm read; + grpc_closure read_done; + grpc_slice_buffer read_slices; + gpr_atm write; + grpc_closure write_done; + grpc_slice_buffer write_slices; + + grpc_slice slice; + char write_buffer[kBufferSize]; + char read_buffer[kBufferSize]; + size_t recv_size = 0; + + init_event_closure(&read_done, &read); + grpc_slice_buffer_init(&read_slices); + grpc_endpoint_read(ep_, &read_slices, &read_done); + + grpc_slice_buffer_init(&write_slices); + slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize); + grpc_slice_buffer_add(&write_slices, slice); + init_event_closure(&write_done, &write); + grpc_endpoint_write(ep_, &write_slices, &write_done); + + XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES); + XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE); + + while (recv_size < kBufferSize) { + ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0); + XCTAssertGreaterThanOrEqual(size, 0); + recv_size += size; + } + + XCTAssertEqual(recv_size, kBufferSize); + XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0); + + close(svr_fd_); + + XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES); + XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE); + + grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE); + grpc_slice_buffer_reset_and_unref(&read_slices); + grpc_slice_buffer_reset_and_unref(&write_slices); +} + +- (void)testRemoteReset { + grpc_core::ExecCtx exec_ctx; + + gpr_atm read; + grpc_closure read_done; + grpc_slice_buffer read_slices; + + init_event_closure(&read_done, &read); + grpc_slice_buffer_init(&read_slices); + grpc_endpoint_read(ep_, &read_slices, &read_done); + + struct linger so_linger; + so_linger.l_onoff = 1; + so_linger.l_linger = 0; + setsockopt(svr_fd_, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)); + + close(svr_fd_); + + XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES); + XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE); + + grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE); + grpc_slice_buffer_reset_and_unref(&read_slices); +} + +@end + +#else // GRPC_CFSTREAM + +// Dummy test suite +@interface CFStreamEndpointTests : XCTestCase +@end + +@implementation CFStreamEndpointTests +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +@end + +#endif // GRPC_CFSTREAM diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..2218f129ae --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj @@ -0,0 +1,338 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 5E143B892069D72200715A6E /* CFStreamClientTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E143B882069D72200715A6E /* CFStreamClientTests.mm */; }; + 5E143B8C206B5F9F00715A6E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5E143B8A2069D72700715A6E /* Info.plist */; }; + 5E143B8E206C5B9A00715A6E /* CFStreamEndpointTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */; }; + 604EA96D9CD477A8EA411BDF /* libPods-CFStreamTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 5E143B792069D67300715A6E /* CFStreamTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CFStreamTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E143B882069D72200715A6E /* CFStreamClientTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CFStreamClientTests.mm; sourceTree = "<group>"; }; + 5E143B8A2069D72700715A6E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CFStreamEndpointTests.mm; sourceTree = "<group>"; }; + 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CFStreamTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CFStreamTests/Pods-CFStreamTests.release.xcconfig"; sourceTree = "<group>"; }; + 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CFStreamTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CFStreamTests/Pods-CFStreamTests.debug.xcconfig"; sourceTree = "<group>"; }; + AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CFStreamTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5E143B762069D67300715A6E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 604EA96D9CD477A8EA411BDF /* libPods-CFStreamTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 5E143B582069D67300715A6E = { + isa = PBXGroup; + children = ( + 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */, + 5E143B8A2069D72700715A6E /* Info.plist */, + 5E143B882069D72200715A6E /* CFStreamClientTests.mm */, + 5E143B622069D67300715A6E /* Products */, + A331D95F7F230B507FBF6D22 /* Pods */, + 6AC36F6C5DB5CA8F717D1B67 /* Frameworks */, + ); + sourceTree = "<group>"; + }; + 5E143B622069D67300715A6E /* Products */ = { + isa = PBXGroup; + children = ( + 5E143B792069D67300715A6E /* CFStreamTests.xctest */, + ); + name = Products; + sourceTree = "<group>"; + }; + 6AC36F6C5DB5CA8F717D1B67 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */, + ); + name = Frameworks; + sourceTree = "<group>"; + }; + A331D95F7F230B507FBF6D22 /* Pods */ = { + isa = PBXGroup; + children = ( + 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */, + 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */, + ); + name = Pods; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 5E143B782069D67300715A6E /* CFStreamTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5E143B852069D67300715A6E /* Build configuration list for PBXNativeTarget "CFStreamTests" */; + buildPhases = ( + 4EBA55D3E23FC6C84596E3D5 /* [CP] Check Pods Manifest.lock */, + 5E143B752069D67300715A6E /* Sources */, + 5E143B762069D67300715A6E /* Frameworks */, + 5E143B772069D67300715A6E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CFStreamTests; + productName = CFStreamTestsTests; + productReference = 5E143B792069D67300715A6E /* CFStreamTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5E143B592069D67300715A6E /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = gRPC; + TargetAttributes = { + 5E143B782069D67300715A6E = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 5E143B5C2069D67300715A6E /* Build configuration list for PBXProject "CFStreamTests" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 5E143B582069D67300715A6E; + productRefGroup = 5E143B622069D67300715A6E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5E143B782069D67300715A6E /* CFStreamTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5E143B772069D67300715A6E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E143B8C206B5F9F00715A6E /* Info.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 4EBA55D3E23FC6C84596E3D5 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-CFStreamTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5E143B752069D67300715A6E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E143B892069D72200715A6E /* CFStreamClientTests.mm in Sources */, + 5E143B8E206C5B9A00715A6E /* CFStreamEndpointTests.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 5E143B802069D67300715A6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 5E143B812069D67300715A6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5E143B862069D67300715A6E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + "$(inherited)", + "PB_FIELD_32BIT=1", + "PB_NO_PACKED_STRUCTS=1", + "GRPC_CFSTREAM=1", + ); + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CFStreamTestsTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../../../..; + }; + name = Debug; + }; + 5E143B872069D67300715A6E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CFStreamTestsTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../../../..; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5E143B5C2069D67300715A6E /* Build configuration list for PBXProject "CFStreamTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E143B802069D67300715A6E /* Debug */, + 5E143B812069D67300715A6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5E143B852069D67300715A6E /* Build configuration list for PBXNativeTarget "CFStreamTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E143B862069D67300715A6E /* Debug */, + 5E143B872069D67300715A6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5E143B592069D67300715A6E /* Project object */; +} diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme new file mode 100644 index 0000000000..25d6f780a1 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5E143B782069D67300715A6E" + BuildableName = "CFStreamTests.xctest" + BlueprintName = "CFStreamTests" + ReferencedContainer = "container:CFStreamTests.xcodeproj"> + </BuildableReference> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme new file mode 100644 index 0000000000..6c5c43aa72 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + enableAddressSanitizer = "YES" + enableASanStackUseAfterReturn = "YES" + language = "" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5E143B782069D67300715A6E" + BuildableName = "CFStreamTests.xctest" + BlueprintName = "CFStreamTests" + ReferencedContainer = "container:CFStreamTests.xcodeproj"> + </BuildableReference> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + enableASanStackUseAfterReturn = "YES" + language = "" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme new file mode 100644 index 0000000000..3e39ff84d0 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5E143B782069D67300715A6E" + BuildableName = "CFStreamTests.xctest" + BlueprintName = "CFStreamTests" + ReferencedContainer = "container:CFStreamTests.xcodeproj"> + </BuildableReference> + </TestableReference> + </Testables> + <AdditionalOptions> + <AdditionalOption + key = "DYLD_INSERT_LIBRARIES" + value = "/usr/lib/libgmalloc.dylib" + isEnabled = "YES"> + </AdditionalOption> + <AdditionalOption + key = "NSZombieEnabled" + value = "YES" + isEnabled = "YES"> + </AdditionalOption> + <AdditionalOption + key = "MallocGuardEdges" + value = "" + isEnabled = "YES"> + </AdditionalOption> + <AdditionalOption + key = "MallocScribble" + value = "" + isEnabled = "YES"> + </AdditionalOption> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme new file mode 100644 index 0000000000..f0bde837c5 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0920" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + enableThreadSanitizer = "YES" + language = "" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5E143B782069D67300715A6E" + BuildableName = "CFStreamTests.xctest" + BlueprintName = "CFStreamTests" + ReferencedContainer = "container:CFStreamTests.xcodeproj"> + </BuildableReference> + </TestableReference> + </Testables> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + stopOnEveryThreadSanitizerIssue = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/test/core/iomgr/ios/CFStreamTests/Info.plist b/test/core/iomgr/ios/CFStreamTests/Info.plist new file mode 100644 index 0000000000..6c40a6cd0c --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/test/core/iomgr/ios/CFStreamTests/Podfile b/test/core/iomgr/ios/CFStreamTests/Podfile new file mode 100644 index 0000000000..630168a363 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/Podfile @@ -0,0 +1,50 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +install! 'cocoapods', :deterministic_uuids => false + +# Location of gRPC's repo root relative to this file. +GRPC_LOCAL_SRC = '../../../../..' + +# Install the dependencies in the main target plus all test targets. +target 'CFStreamTests' do + pod 'gRPC-Core/CFStream-Implementation', :path => GRPC_LOCAL_SRC +end + +pre_install do |installer| + # This is the gRPC-Core podspec object, as initialized by its podspec file. + grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec + + # Copied from gRPC-Core.podspec, except for the adjusted src_root: + src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' + end + + # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include + # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core' + # and require the same error suppresion. + if target.name.start_with?('gRPC-Core') + target.build_configurations.each do |config| + # TODO(zyc): Remove this setting after the issue is resolved + # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void + # function" warning + config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' + end + end + end +end diff --git a/test/core/iomgr/ios/CFStreamTests/build_tests.sh b/test/core/iomgr/ios/CFStreamTests/build_tests.sh new file mode 100755 index 0000000000..d23f26f5db --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/build_tests.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -e + +# CocoaPods requires the terminal to be using UTF-8 encoding. +export LANG=en_US.UTF-8 + +cd "$(dirname "$0")" + +hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; } +hash xcodebuild 2>/dev/null || { + echo >&2 "XCode command-line tools need to be installed." + exit 1 +} + +# clean the directory +rm -rf Pods +rm -rf CFStreamTests.xcworkspace +rm -f Podfile.lock + +echo "TIME: $(date)" +pod install + diff --git a/test/core/iomgr/ios/CFStreamTests/run_tests.sh b/test/core/iomgr/ios/CFStreamTests/run_tests.sh new file mode 100755 index 0000000000..1045ec10a8 --- /dev/null +++ b/test/core/iomgr/ios/CFStreamTests/run_tests.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -ev + +cd "$(dirname "$0")" + +echo "TIME: $(date)" + +XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' + +xcodebuild \ + -workspace CFStreamTests.xcworkspace \ + -scheme CFStreamTests \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + +echo "TIME: $(date)" + +xcodebuild \ + -workspace CFStreamTests.xcworkspace \ + -scheme CFStreamTests_Asan \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + +echo "TIME: $(date)" + +xcodebuild \ + -workspace CFStreamTests.xcworkspace \ + -scheme CFStreamTests_Tsan \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - + +echo "TIME: $(date)" + +xcodebuild \ + -workspace CFStreamTests.xcworkspace \ + -scheme CFStreamTests_Msan \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc index 0dc75a5f3f..1aae1daa02 100644 --- a/test/core/iomgr/pollset_set_test.cc +++ b/test/core/iomgr/pollset_set_test.cc @@ -118,7 +118,7 @@ static void init_test_fds(test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd)); tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd), - "test_fd"); + "test_fd", false); reset_test_fd(&tfds[i]); } } @@ -136,8 +136,7 @@ static void cleanup_test_fds(test_fd* tfds, const int num_fds) { * grpc_wakeup_fd and we would like to destroy it ourselves (by calling * grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the * underlying fd, call it with a non-NULL 'release_fd' parameter */ - grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */, - "test_fd_cleanup"); + grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, "test_fd_cleanup"); grpc_core::ExecCtx::Get()->Flush(); grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd); diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc index f4df6fca23..3e87831e44 100644 --- a/test/core/iomgr/tcp_posix_test.cc +++ b/test/core/iomgr/tcp_posix_test.cc @@ -176,7 +176,8 @@ static void read_test(size_t num_bytes, size_t slice_size) { a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = static_cast<int>(slice_size); grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; - ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test"); + ep = + grpc_tcp_create(grpc_fd_create(sv[1], "read_test", false), &args, "test"); grpc_endpoint_add_to_pollset(ep, g_pollset); written_bytes = fill_socket_partial(sv[0], num_bytes); @@ -226,7 +227,8 @@ static void large_read_test(size_t slice_size) { a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = static_cast<int>(slice_size); grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; - ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test"); + ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test", false), &args, + "test"); grpc_endpoint_add_to_pollset(ep, g_pollset); written_bytes = fill_socket(sv[0]); @@ -365,7 +367,8 @@ static void write_test(size_t num_bytes, size_t slice_size) { a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = static_cast<int>(slice_size); grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; - ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test"); + ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test", false), &args, + "test"); grpc_endpoint_add_to_pollset(ep, g_pollset); state.ep = ep; @@ -433,7 +436,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = static_cast<int>(slice_size); grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; - ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test"); + ep = + grpc_tcp_create(grpc_fd_create(sv[1], "read_test", false), &args, "test"); GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0); grpc_endpoint_add_to_pollset(ep, g_pollset); @@ -522,10 +526,10 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = static_cast<int>(slice_size); grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; - f.client_ep = - grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test"); - f.server_ep = - grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"), &args, "test"); + f.client_ep = grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client", false), + &args, "test"); + f.server_ep = grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server", false), + &args, "test"); grpc_resource_quota_unref_internal(resource_quota); grpc_endpoint_add_to_pollset(f.client_ep, g_pollset); grpc_endpoint_add_to_pollset(f.server_ep, g_pollset); diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 70bcc8c9c3..12aa84d93b 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -183,6 +183,7 @@ grpc_cc_test( "//:gpr", "//:gpr_base", "//:grpc", + "//test/core/util:gpr_test_util", ], ) @@ -195,6 +196,7 @@ grpc_cc_test( "//:gpr", "//:gpr_base", "//:grpc", + "//test/core/util:gpr_test_util", ], ) @@ -206,6 +208,7 @@ grpc_cc_test( "//:alts_util", "//:gpr", "//:grpc", + "//test/core/util:gpr_test_util", ], ) @@ -220,5 +223,6 @@ grpc_cc_test( "//:grpc_secure", "//:tsi", "//:tsi_interface", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD index 84fb3a1421..7ca1c1d943 100644 --- a/test/core/transport/BUILD +++ b/test/core/transport/BUILD @@ -129,6 +129,7 @@ grpc_cc_test( language = "C++", deps = [ "//:grpc", + "//test/core/util:gpr_test_util", ], external_deps = [ "gtest", diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc index 1ed6ccfba6..f7b3c62a40 100644 --- a/test/core/transport/status_conversion_test.cc +++ b/test/core/transport/status_conversion_test.cc @@ -33,12 +33,7 @@ #define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b)) -int main(int argc, char** argv) { - int i; - - grpc_test_init(argc, argv); - grpc_init(); - +static void test_grpc_status_to_http2_error() { GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR); @@ -65,7 +60,9 @@ int main(int argc, char** argv) { GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE, GRPC_HTTP2_REFUSED_STREAM); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR); +} +static void test_grpc_status_to_http2_status() { GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNKNOWN, 200); @@ -83,7 +80,9 @@ int main(int argc, char** argv) { GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_INTERNAL, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200); +} +static void test_http2_error_to_grpc_status() { const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE; HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline, GRPC_STATUS_INTERNAL); @@ -144,7 +143,9 @@ int main(int argc, char** argv) { GRPC_STATUS_RESOURCE_EXHAUSTED); HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline, GRPC_STATUS_PERMISSION_DENIED); +} +static void test_http2_status_to_grpc_status() { HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK); HTTP2_STATUS_TO_GRPC_STATUS(400, GRPC_STATUS_INVALID_ARGUMENT); HTTP2_STATUS_TO_GRPC_STATUS(401, GRPC_STATUS_UNAUTHENTICATED); @@ -157,6 +158,18 @@ int main(int argc, char** argv) { HTTP2_STATUS_TO_GRPC_STATUS(500, GRPC_STATUS_UNKNOWN); HTTP2_STATUS_TO_GRPC_STATUS(503, GRPC_STATUS_UNAVAILABLE); HTTP2_STATUS_TO_GRPC_STATUS(504, GRPC_STATUS_DEADLINE_EXCEEDED); +} + +int main(int argc, char** argv) { + int i; + + grpc_test_init(argc, argv); + grpc_init(); + + test_grpc_status_to_http2_error(); + test_grpc_status_to_http2_status(); + test_http2_error_to_grpc_status(); + test_http2_status_to_grpc_status(); /* check all status values can be converted */ for (i = 0; i <= 999; i++) { diff --git a/test/core/tsi/alts/crypt/BUILD b/test/core/tsi/alts/crypt/BUILD index cf9dbca316..abe1e83656 100644 --- a/test/core/tsi/alts/crypt/BUILD +++ b/test/core/tsi/alts/crypt/BUILD @@ -27,6 +27,7 @@ grpc_cc_test( "//:alts_frame_protector", "//:gpr", "//:grpc", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/core/tsi/alts/frame_protector/BUILD b/test/core/tsi/alts/frame_protector/BUILD index dd1966b379..6ff3015f4d 100644 --- a/test/core/tsi/alts/frame_protector/BUILD +++ b/test/core/tsi/alts/frame_protector/BUILD @@ -27,6 +27,7 @@ grpc_cc_test( "//:gpr", "//:grpc", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) @@ -39,6 +40,7 @@ grpc_cc_test( "//:gpr", "//:grpc", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) @@ -54,6 +56,7 @@ grpc_cc_test( "//:tsi_interface", "//test/core/tsi/alts/crypt:alts_crypt_test_util", "//test/core/tsi:transport_security_test_lib", + "//test/core/util:gpr_test_util", ], ) @@ -67,5 +70,6 @@ grpc_cc_test( "//:gpr_base", "//:grpc", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/core/tsi/alts/handshaker/BUILD b/test/core/tsi/alts/handshaker/BUILD index 809742744c..3f1a681c1a 100644 --- a/test/core/tsi/alts/handshaker/BUILD +++ b/test/core/tsi/alts/handshaker/BUILD @@ -37,6 +37,7 @@ grpc_cc_test( "//:tsi", "//:tsi_interface", "//:grpc", + "//test/core/util:gpr_test_util", ], ) @@ -47,6 +48,7 @@ grpc_cc_test( deps = [ ":alts_handshaker_service_api_test_lib", "//:grpc", + "//test/core/util:gpr_test_util", ], ) @@ -60,6 +62,7 @@ grpc_cc_test( "//:gpr_base", "//:grpc", "//:tsi", + "//test/core/util:gpr_test_util", ], ) @@ -71,6 +74,7 @@ grpc_cc_test( ":alts_handshaker_service_api_test_lib", "//:grpc", "//:tsi", + "//test/core/util:gpr_test_util", ], ) @@ -81,6 +85,7 @@ grpc_cc_test( deps = [ "//:alts_util", "//:grpc", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/core/tsi/alts/zero_copy_frame_protector/BUILD b/test/core/tsi/alts/zero_copy_frame_protector/BUILD index 2b41dae043..a3b797327e 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/BUILD +++ b/test/core/tsi/alts/zero_copy_frame_protector/BUILD @@ -28,6 +28,7 @@ grpc_cc_test( "//:grpc", "//:grpc_base_c", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) @@ -40,6 +41,7 @@ grpc_cc_test( "//:gpr", "//:grpc", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) @@ -53,5 +55,6 @@ grpc_cc_test( "//:grpc", "//:grpc_base_c", "//test/core/tsi/alts/crypt:alts_crypt_test_util", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/core/util/BUILD b/test/core/util/BUILD index f52570cde5..be3e204777 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -32,6 +32,11 @@ grpc_cc_library( "test_config.h", ], deps = ["//:gpr"], + data = [ + "//tools:lsan_suppressions.txt", + "//tools:tsan_suppressions.txt", + "//tools:ubsan_suppressions.txt", + ], ) grpc_cc_library( diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD index 12825e88c2..c03ea92d34 100644 --- a/test/cpp/client/BUILD +++ b/test/cpp/client/BUILD @@ -28,6 +28,7 @@ grpc_cc_test( "//:gpr", "//:grpc", "//:grpc++", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 60238e930d..3c1d48cc1e 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1209,8 +1209,13 @@ TEST_P(End2endTest, ExpectErrorTest) { std::vector<ErrorStatus> expected_status; expected_status.emplace_back(); expected_status.back().set_code(13); // INTERNAL + // No Error message or details + + expected_status.emplace_back(); + expected_status.back().set_code(13); // INTERNAL expected_status.back().set_error_message("text error message"); expected_status.back().set_binary_error_details("text error details"); + expected_status.emplace_back(); expected_status.back().set_code(13); // INTERNAL expected_status.back().set_error_message("text error message"); diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 7aab035e76..28f9ae6f40 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -1380,7 +1380,7 @@ TEST_F(SingleBalancerTest, DropAll) { class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest { public: - SingleBalancerWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 1, 2) {} + SingleBalancerWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 1, 3) {} }; TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 5dcfd94ed3..d51a0e3dc5 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -24,6 +24,7 @@ grpc_cc_test( external_deps = [ "benchmark", ], + deps = ["//test/core/util:gpr_test_util",] ) grpc_cc_library( diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index bcb68ff229..050c7f7c17 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -141,12 +141,12 @@ static void BM_PollAddFd(benchmark::State& state) { grpc_wakeup_fd wakeup_fd; GPR_ASSERT( GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd))); - grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx"); + grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx", false); while (state.KeepRunning()) { grpc_pollset_add_fd(ps, fd); grpc_core::ExecCtx::Get()->Flush(); } - grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx"); + grpc_fd_orphan(fd, nullptr, nullptr, "xxx"); grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); @@ -222,7 +222,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; grpc_wakeup_fd wakeup_fd; GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd)); - grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read"); + grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read", false); grpc_pollset_add_fd(ps, wakeup); bool done = false; Closure* continue_closure = MakeClosure( @@ -242,7 +242,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { while (!done) { GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE)); } - grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done"); + grpc_fd_orphan(wakeup, nullptr, nullptr, "done"); wakeup_fd.read_fd = 0; grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index fa0b216f8f..2925e8fbcf 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -22,7 +22,7 @@ package( licenses(["notice"]) # Apache v2 -load("//bazel:grpc_build_system.bzl", "grpc_py_binary") +load("//bazel:grpc_build_system.bzl", "grpc_py_binary", "grpc_cc_test") load(":generate_resolver_component_tests.bzl", "generate_resolver_component_tests") @@ -35,4 +35,20 @@ grpc_py_binary( testonly = True, ) +grpc_cc_test( + name = "cancel_ares_query_test", + srcs = ["cancel_ares_query_test.cc"], + external_deps = ["gmock"], + deps = [ + "//test/cpp/util:test_util", + "//test/core/util:grpc_test_util", + "//test/core/util:gpr_test_util", + "//:grpc++", + "//:grpc", + "//:gpr", + "//test/cpp/util:test_config", + "//test/core/end2end:cq_verifier", + ], +) + generate_resolver_component_tests() diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc new file mode 100644 index 0000000000..11cdc0b774 --- /dev/null +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -0,0 +1,289 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <stdio.h> +#include <string.h> + +#include <gflags/gflags.h> +#include <gmock/gmock.h> + +#include <grpc/byte_buffer.h> +#include <grpc/grpc.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/time.h> +#include "include/grpc/support/string_util.h" +#include "src/core/ext/filters/client_channel/resolver.h" +#include "src/core/ext/filters/client_channel/resolver_registry.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/orphanable.h" +#include "src/core/lib/gprpp/thd.h" +#include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/pollset_set.h" +#include "test/core/end2end/cq_verifier.h" +#include "test/core/util/cmdline.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" + +// TODO: pull in different headers when enabling this +// test on windows. Also set BAD_SOCKET_RETURN_VAL +// to INVALID_SOCKET on windows. +#include "src/core/lib/iomgr/sockaddr_posix.h" +#define BAD_SOCKET_RETURN_VAL -1 + +namespace { + +void* Tag(intptr_t t) { return (void*)t; } + +gpr_timespec FiveSecondsFromNow(void) { + return grpc_timeout_seconds_to_deadline(5); +} + +void DrainCq(grpc_completion_queue* cq) { + grpc_event ev; + do { + ev = grpc_completion_queue_next(cq, FiveSecondsFromNow(), nullptr); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); +} + +void EndTest(grpc_channel* client, grpc_completion_queue* cq) { + grpc_channel_destroy(client); + grpc_completion_queue_shutdown(cq); + DrainCq(cq); + grpc_completion_queue_destroy(cq); +} + +class FakeNonResponsiveDNSServer { + public: + FakeNonResponsiveDNSServer(int port) { + socket_ = socket(AF_INET6, SOCK_DGRAM, 0); + if (socket_ == BAD_SOCKET_RETURN_VAL) { + gpr_log(GPR_DEBUG, "Failed to create UDP ipv6 socket"); + abort(); + } + sockaddr_in6 addr; + memset(&addr, 0, sizeof(addr)); + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(port); + ((char*)&addr.sin6_addr)[15] = 1; + if (bind(socket_, (const sockaddr*)&addr, sizeof(addr)) != 0) { + gpr_log(GPR_DEBUG, "Failed to bind UDP ipv6 socket to [::1]:%d", port); + abort(); + } + } + ~FakeNonResponsiveDNSServer() { close(socket_); } + + private: + int socket_; +}; + +struct ArgsStruct { + gpr_atm done_atm; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; + grpc_combiner* lock; + grpc_channel_args* channel_args; +}; + +void ArgsInit(ArgsStruct* args) { + args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); + grpc_pollset_init(args->pollset, &args->mu); + args->pollset_set = grpc_pollset_set_create(); + grpc_pollset_set_add_pollset(args->pollset_set, args->pollset); + args->lock = grpc_combiner_create(); + gpr_atm_rel_store(&args->done_atm, 0); + args->channel_args = nullptr; +} + +void DoNothing(void* arg, grpc_error* error) {} + +void ArgsFinish(ArgsStruct* args) { + grpc_pollset_set_del_pollset(args->pollset_set, args->pollset); + grpc_pollset_set_destroy(args->pollset_set); + grpc_closure DoNothing_cb; + GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr, + grpc_schedule_on_exec_ctx); + grpc_pollset_shutdown(args->pollset, &DoNothing_cb); + // exec_ctx needs to be flushed before calling grpc_pollset_destroy() + grpc_channel_args_destroy(args->channel_args); + grpc_core::ExecCtx::Get()->Flush(); + grpc_pollset_destroy(args->pollset); + gpr_free(args->pollset); + GRPC_COMBINER_UNREF(args->lock, nullptr); +} + +void PollPollsetUntilRequestDone(ArgsStruct* args) { + while (true) { + bool done = gpr_atm_acq_load(&args->done_atm) != 0; + if (done) { + break; + } + grpc_pollset_worker* worker = nullptr; + grpc_core::ExecCtx exec_ctx; + gpr_mu_lock(args->mu); + GRPC_LOG_IF_ERROR( + "pollset_work", + grpc_pollset_work(args->pollset, &worker, + grpc_timespec_to_millis_round_up( + gpr_inf_future(GPR_CLOCK_REALTIME)))); + gpr_mu_unlock(args->mu); + } +} + +void CheckResolverResultAssertFailureLocked(void* arg, grpc_error* error) { + EXPECT_NE(error, GRPC_ERROR_NONE); + ArgsStruct* args = static_cast<ArgsStruct*>(arg); + gpr_atm_rel_store(&args->done_atm, 1); + gpr_mu_lock(args->mu); + GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr)); + gpr_mu_unlock(args->mu); +} + +TEST(CancelDuringAresQuery, TestCancelActiveDNSQuery) { + grpc_core::ExecCtx exec_ctx; + ArgsStruct args; + ArgsInit(&args); + int fake_dns_port = grpc_pick_unused_port_or_die(); + FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); + char* client_target; + GPR_ASSERT(gpr_asprintf( + &client_target, + "dns://[::1]:%d/dont-care-since-wont-be-resolved.test.com:1234", + fake_dns_port)); + // create resolver and resolve + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + grpc_core::ResolverRegistry::CreateResolver(client_target, nullptr, + args.pollset_set, args.lock); + gpr_free(client_target); + grpc_closure on_resolver_result_changed; + GRPC_CLOSURE_INIT(&on_resolver_result_changed, + CheckResolverResultAssertFailureLocked, (void*)&args, + grpc_combiner_scheduler(args.lock)); + resolver->NextLocked(&args.channel_args, &on_resolver_result_changed); + // Without resetting and causing resolver shutdown, the + // PollPollsetUntilRequestDone call should never finish. + resolver.reset(); + grpc_core::ExecCtx::Get()->Flush(); + PollPollsetUntilRequestDone(&args); + ArgsFinish(&args); +} + +TEST(CancelDuringAresQuery, + TestHitDeadlineAndDestroyChannelDuringAresResolutionIsGraceful) { + // Start up fake non responsive DNS server + int fake_dns_port = grpc_pick_unused_port_or_die(); + FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); + // Create a call that will try to use the fake DNS server + char* client_target = nullptr; + GPR_ASSERT(gpr_asprintf( + &client_target, + "dns://[::1]:%d/dont-care-since-wont-be-resolved.test.com:1234", + fake_dns_port)); + grpc_channel* client = + grpc_insecure_channel_create(client_target, + /* client_args */ nullptr, nullptr); + gpr_free(client_target); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); + cq_verifier* cqv = cq_verifier_create(cq); + gpr_timespec deadline = grpc_timeout_milliseconds_to_deadline(10); + grpc_call* call = grpc_channel_create_call( + client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); + GPR_ASSERT(call); + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details call_details; + grpc_call_details_init(&call_details); + grpc_status_code status; + const char* error_string; + grpc_slice details; + // Set ops for client the request + grpc_op ops_base[6]; + memset(ops_base, 0, sizeof(ops_base)); + grpc_op* op = ops_base; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.error_string = &error_string; + op->flags = 0; + op->reserved = nullptr; + op++; + // Run the call and sanity check it failed as expected + grpc_call_error error = grpc_call_start_batch( + call, ops_base, static_cast<size_t>(op - ops_base), Tag(1), nullptr); + EXPECT_EQ(GRPC_CALL_OK, error); + CQ_EXPECT_COMPLETION(cqv, Tag(1), 1); + cq_verify(cqv); + EXPECT_EQ(status, GRPC_STATUS_DEADLINE_EXCEEDED); + // Teardown + grpc_slice_unref(details); + gpr_free((void*)error_string); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + grpc_call_unref(call); + cq_verifier_destroy(cqv); + EndTest(client, cq); +} + +} // namespace + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + // Sanity check the time that it takes to run the test + // including the teardown time (the teardown + // part of the test involves cancelling the DNS query, + // which is the main point of interest for this test). + gpr_timespec overall_deadline = grpc_timeout_seconds_to_deadline(4); + grpc_init(); + auto result = RUN_ALL_TESTS(); + grpc_shutdown(); + if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) { + gpr_log(GPR_ERROR, "Test took too long"); + abort(); + } + return result; +} diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py index a0767b21cf..baa6512f62 100755 --- a/test/cpp/naming/gen_build_yaml.py +++ b/test/cpp/naming/gen_build_yaml.py @@ -121,6 +121,25 @@ def main(): 'grpc++_test_config', ], } for unsecure_build_config_suffix in ['_unsecure', ''] + ] + [ + { + 'name': 'cancel_ares_query_test', + 'build': 'test', + 'language': 'c++', + 'gtest': True, + 'run': True, + 'src': ['test/cpp/naming/cancel_ares_query_test.cc'], + 'platforms': ['linux', 'posix', 'mac'], + 'deps': [ + 'grpc++_test_util', + 'grpc_test_util', + 'gpr_test_util', + 'grpc++', + 'grpc', + 'gpr', + 'grpc++_test_config', + ], + }, ] } diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index f4be064305..07ddfd30ee 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -22,10 +22,14 @@ #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> + #include <string.h> +#include <errno.h> +#include <fcntl.h> #include <gflags/gflags.h> #include <gmock/gmock.h> +#include <thread> #include <vector> #include "test/cpp/util/subprocess.h" @@ -48,6 +52,12 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" +// TODO: pull in different headers when enabling this +// test on windows. Also set BAD_SOCKET_RETURN_VAL +// to INVALID_SOCKET on windows. +#include "src/core/lib/iomgr/sockaddr_posix.h" +#define BAD_SOCKET_RETURN_VAL -1 + using grpc::SubProcess; using std::vector; using testing::UnorderedElementsAreArray; @@ -231,7 +241,79 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_args, } } +void OpenAndCloseSocketsStressLoop(int dummy_port, gpr_event* done_ev) { + // The goal of this loop is to catch socket + // "use after close" bugs within the c-ares resolver by acting + // like some separate thread doing I/O. + // It's goal is to try to hit race conditions whereby: + // 1) The c-ares resolver closes a socket. + // 2) This loop opens a socket with (coincidentally) the same handle. + // 3) the c-ares resolver mistakenly uses that same socket without + // realizing that its closed. + // 4) This loop performs an operation on that socket that should + // succeed but instead fails because of what the c-ares + // resolver did in the meantime. + sockaddr_in6 addr; + memset(&addr, 0, sizeof(addr)); + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(dummy_port); + ((char*)&addr.sin6_addr)[15] = 1; + for (;;) { + if (gpr_event_get(done_ev)) { + return; + } + std::vector<int> sockets; + // First open a bunch of sockets, bind and listen + // '50' is an arbitrary number that, experimentally, + // has a good chance of catching bugs. + for (size_t i = 0; i < 50; i++) { + int s = socket(AF_INET6, SOCK_STREAM, 0); + int val = 1; + ASSERT_TRUE(setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)) == + 0) + << "Failed to set socketopt reuseport"; + ASSERT_TRUE(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) == + 0) + << "Failed to set socket reuseaddr"; + ASSERT_TRUE(fcntl(s, F_SETFL, O_NONBLOCK) == 0) + << "Failed to set socket non-blocking"; + ASSERT_TRUE(s != BAD_SOCKET_RETURN_VAL) + << "Failed to create TCP ipv6 socket"; + gpr_log(GPR_DEBUG, "Opened fd: %d", s); + ASSERT_TRUE(bind(s, (const sockaddr*)&addr, sizeof(addr)) == 0) + << "Failed to bind socket " + std::to_string(s) + + " to [::1]:" + std::to_string(dummy_port) + + ". errno: " + std::to_string(errno); + ASSERT_TRUE(listen(s, 1) == 0) << "Failed to listen on socket " + + std::to_string(s) + + ". errno: " + std::to_string(errno); + sockets.push_back(s); + } + // Do a non-blocking accept followed by a close on all of those sockets. + // Do this in a separate loop to try to induce a time window to hit races. + for (size_t i = 0; i < sockets.size(); i++) { + gpr_log(GPR_DEBUG, "non-blocking accept then close on %d", sockets[i]); + if (accept(sockets[i], nullptr, nullptr)) { + // If e.g. a "shutdown" was called on this fd from another thread, + // then this accept call should fail with an unexpected error. + ASSERT_TRUE(errno == EAGAIN || errno == EWOULDBLOCK) + << "OpenAndCloseSocketsStressLoop accept on socket " + + std::to_string(sockets[i]) + + " failed in " + "an unexpected way. " + "errno: " + + std::to_string(errno) + + ". Socket use-after-close bugs are likely."; + } + ASSERT_TRUE(close(sockets[i]) == 0) + << "Failed to close socket: " + std::to_string(sockets[i]) + + ". errno: " + std::to_string(errno); + } + } +} + void CheckResolverResultLocked(void* argsp, grpc_error* err) { + EXPECT_EQ(err, GRPC_ERROR_NONE); ArgsStruct* args = (ArgsStruct*)argsp; grpc_channel_args* channel_args = args->channel_args; const grpc_arg* channel_arg = @@ -271,7 +353,17 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) { gpr_mu_unlock(args->mu); } -TEST(ResolverComponentTest, TestResolvesRelevantRecords) { +void CheckResolvedWithoutErrorLocked(void* argsp, grpc_error* err) { + EXPECT_EQ(err, GRPC_ERROR_NONE); + ArgsStruct* args = (ArgsStruct*)argsp; + gpr_atm_rel_store(&args->done_atm, 1); + gpr_mu_lock(args->mu); + GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr)); + gpr_mu_unlock(args->mu); +} + +void RunResolvesRelevantRecordsTest(void (*OnDoneLocked)(void* arg, + grpc_error* error)) { grpc_core::ExecCtx exec_ctx; ArgsStruct args; ArgsInit(&args); @@ -289,14 +381,32 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { args.pollset_set, args.lock); gpr_free(whole_uri); grpc_closure on_resolver_result_changed; - GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked, - (void*)&args, grpc_combiner_scheduler(args.lock)); + GRPC_CLOSURE_INIT(&on_resolver_result_changed, OnDoneLocked, (void*)&args, + grpc_combiner_scheduler(args.lock)); resolver->NextLocked(&args.channel_args, &on_resolver_result_changed); grpc_core::ExecCtx::Get()->Flush(); PollPollsetUntilRequestDone(&args); ArgsFinish(&args); } +TEST(ResolverComponentTest, TestResolvesRelevantRecords) { + RunResolvesRelevantRecordsTest(CheckResolverResultLocked); +} + +TEST(ResolverComponentTest, TestResolvesRelevantRecordsWithConcurrentFdStress) { + // Start up background stress thread + int dummy_port = grpc_pick_unused_port_or_die(); + gpr_event done_ev; + gpr_event_init(&done_ev); + std::thread socket_stress_thread(OpenAndCloseSocketsStressLoop, dummy_port, + &done_ev); + // Run the resolver test + RunResolvesRelevantRecordsTest(CheckResolvedWithoutErrorLocked); + // Shutdown and join stress thread + gpr_event_set(&done_ev, (void*)1); + socket_stress_thread.join(); +} + } // namespace int main(int argc, char** argv) { diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index b1153d2df3..9b42bb28b1 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -217,6 +217,7 @@ grpc_cc_test( ], deps = [ "//:grpc++", + "//test/core/util:gpr_test_util", ], ) @@ -260,6 +261,7 @@ grpc_cc_test( deps = [ "//:grpc++_error_details", "//src/proto/grpc/testing:echo_messages_proto", + "//test/core/util:gpr_test_util", ], ) diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index 195b6bd304..840ca07d2b 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -471,17 +471,26 @@ bool GrpcTool::CallMethod(int argc, const char** argv, std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_address, cred.GetCredentials()); - parser.reset(new grpc::testing::ProtoFileParser( - FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles)); + if (!FLAGS_binary_input || !FLAGS_binary_output) { + parser.reset( + new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr, + FLAGS_proto_path, FLAGS_protofiles)); + if (parser->HasError()) { + fprintf( + stderr, + "Failed to find remote reflection service and local proto files.\n"); + return false; + } + } if (FLAGS_binary_input) { formatted_method_name = method_name; } else { formatted_method_name = parser->GetFormattedMethodName(method_name); - } - - if (parser->HasError()) { - return false; + if (parser->HasError()) { + fprintf(stderr, "Failed to find method %s in proto files.\n", + method_name.c_str()); + } } if (argc == 3) { @@ -711,6 +720,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv, serialized_request_proto = parser->GetSerializedProtoFromMethod( method_name, request_text, true /* is_request */); if (parser->HasError()) { + fprintf(stderr, "Failed to parse request.\n"); return false; } } @@ -735,6 +745,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv, serialized_response_proto = parser->GetTextFormatFromMethod( method_name, serialized_response_proto, false /* is_request */); if (parser->HasError()) { + fprintf(stderr, "Failed to parse response.\n"); return false; } } @@ -814,6 +825,9 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles)); if (parser->HasError()) { + fprintf( + stderr, + "Failed to find remote reflection service and local proto files.\n"); return false; } } @@ -824,6 +838,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, serialized_request_proto = parser->GetSerializedProtoFromMessageType(type_name, message_text); if (parser->HasError()) { + fprintf(stderr, "Failed to serialize the message.\n"); return false; } } @@ -834,6 +849,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, grpc::string output_text = parser->GetTextFormatFromMessageType( type_name, serialized_request_proto); if (parser->HasError()) { + fprintf(stderr, "Failed to deserialize the message.\n"); return false; } output_ss << output_text << std::endl; diff --git a/test/distrib/csharp/DistribTest/packages.config b/test/distrib/csharp/DistribTest/packages.config index 84be8f76b5..3cb2c46bcf 100644 --- a/test/distrib/csharp/DistribTest/packages.config +++ b/test/distrib/csharp/DistribTest/packages.config @@ -6,6 +6,7 @@ <package id="Grpc" version="__GRPC_NUGET_VERSION__" targetFramework="net45" /> <package id="Grpc.Auth" version="__GRPC_NUGET_VERSION__" targetFramework="net45" /> <package id="Grpc.Core" version="__GRPC_NUGET_VERSION__" targetFramework="net45" /> + <package id="Grpc.Tools" version="__GRPC_NUGET_VERSION__" targetFramework="net45" /> <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh index eee24d0e57..f9371410e7 100755 --- a/test/distrib/csharp/run_distrib_test.sh +++ b/test/distrib/csharp/run_distrib_test.sh @@ -26,3 +26,6 @@ nuget restore xbuild DistribTest.sln mono DistribTest/bin/Debug/DistribTest.exe + +# test that codegen work +test_codegen/test_codegen.sh diff --git a/test/distrib/csharp/test_codegen/test_codegen.sh b/test/distrib/csharp/test_codegen/test_codegen.sh new file mode 100755 index 0000000000..fa101889f6 --- /dev/null +++ b/test/distrib/csharp/test_codegen/test_codegen.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cd "$(dirname "$0")" + +ls -lR "../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools" + +PLATFORM_ARCH=linux_x64 +if [ "$(uname)" == "Darwin" ] +then + PLATFORM_ARCH=macosx_x64 +elif [ "$(getconf LONG_BIT)" == "32" ] +then + PLATFORM_ARCH=linux_x86 +fi + +PROTOC=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/protoc +PLUGIN=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/grpc_csharp_plugin + +"${PROTOC}" --plugin="protoc-gen-grpc=${PLUGIN}" --csharp_out=. --grpc_out=. -I . testcodegen.proto + +ls ./*.cs + +echo 'Code generation works.' diff --git a/test/distrib/csharp/test_codegen/testcodegen.proto b/test/distrib/csharp/test_codegen/testcodegen.proto new file mode 100644 index 0000000000..5c228b81db --- /dev/null +++ b/test/distrib/csharp/test_codegen/testcodegen.proto @@ -0,0 +1,29 @@ +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package testcodegen; + +service Greeter { + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh index 9759cc5648..0e47ed3abd 100755 --- a/test/distrib/csharp/update_version.sh +++ b/test/distrib/csharp/update_version.sh @@ -28,4 +28,4 @@ then fi # Replaces version placeholder with value provided as first argument. -sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj +sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj test_codegen/test_codegen.sh diff --git a/third_party/cares/BUILD b/third_party/cares/BUILD index ad27d93c0f..d73f5516bc 100644 --- a/third_party/cares/BUILD +++ b/third_party/cares/BUILD @@ -6,4 +6,5 @@ exports_files([ "config_freebsd/ares_config.h", "config_linux/ares_config.h", "config_openbsd/ares_config.h", + "config_windows/ares_config.h", ]) diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD index 3ac02875e6..fd14007e80 100644 --- a/third_party/cares/cares.BUILD +++ b/third_party/cares/cares.BUILD @@ -3,6 +3,11 @@ config_setting( values = {"cpu": "darwin"}, ) +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + # Android is not officially supported through C++. # This just helps with the build for now. config_setting( @@ -49,6 +54,7 @@ genrule( ":ios_armv7s": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":ios_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":darwin": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":windows": ["@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h"], ":android": ["@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h"], "//conditions:default": ["@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h"], }), @@ -138,10 +144,22 @@ cc_library( copts = [ "-D_GNU_SOURCE", "-D_HAS_EXCEPTIONS=0", - "-DNOMINMAX", "-DHAVE_CONFIG_H", - ], + ] + select({ + ":windows": [ + "-DNOMINMAX", + "-D_CRT_SECURE_NO_DEPRECATE", + "-D_CRT_NONSTDC_NO_DEPRECATE", + "-D_WIN32_WINNT=0x0600", + ], + "//conditions:default": [], + }), + defines = ["CARES_STATICLIB"], includes = ["."], + linkopts = select({ + ":windows": ["-defaultlib:ws2_32.lib"], + "//conditions:default": [], + }), linkstatic = 1, visibility = [ "//visibility:public", diff --git a/third_party/cares/config_windows/ares_config.h b/third_party/cares/config_windows/ares_config.h new file mode 100644 index 0000000000..a128faac37 --- /dev/null +++ b/third_party/cares/config_windows/ares_config.h @@ -0,0 +1,423 @@ +/* Generated from ares_config.h.cmake*/ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* define this if ares is built for a big endian system */ +#undef ARES_BIG_ENDIAN + +/* when building as static part of libcurl */ +#undef BUILDING_LIBCURL + +/* Defined for build that exposes internal static functions for testing. */ +#undef CARES_EXPOSE_STATICS + +/* Defined for build with symbol hiding. */ +#undef CARES_SYMBOL_HIDING + +/* Definition to make a library symbol externally visible. */ +#undef CARES_SYMBOL_SCOPE_EXTERN + +/* Use resolver library to configure cares */ +/* #undef CARES_USE_LIBRESOLV */ + +/* if a /etc/inet dir is being used */ +#undef ETC_INET + +/* Define to the type of arg 2 for gethostname. */ +#define GETHOSTNAME_TYPE_ARG2 int + +/* Define to the type qualifier of arg 1 for getnameinfo. */ +#define GETNAMEINFO_QUAL_ARG1 + +/* Define to the type of arg 1 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * + +/* Define to the type of arg 2 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG2 socklen_t + +/* Define to the type of args 4 and 6 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG46 socklen_t + +/* Define to the type of arg 7 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG7 int + +/* Specifies the number of arguments to getservbyport_r */ +#define GETSERVBYPORT_R_ARGS + +/* Define to 1 if you have AF_INET6. */ +#define HAVE_AF_INET6 + +/* Define to 1 if you have the <arpa/inet.h> header file. */ +/* #undef HAVE_ARPA_INET_H */ + +/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */ +/* #undef HAVE_ARPA_NAMESER_COMPAT_H */ + +/* Define to 1 if you have the <arpa/nameser.h> header file. */ +/* #undef HAVE_ARPA_NAMESER_H */ + +/* Define to 1 if you have the <assert.h> header file. */ +#define HAVE_ASSERT_H + +/* Define to 1 if you have the `bitncmp' function. */ +/* #undef HAVE_BITNCMP */ + +/* Define to 1 if bool is an available type. */ +#define HAVE_BOOL_T + +/* Define to 1 if you have the clock_gettime function and monotonic timer. */ +/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */ + +/* Define to 1 if you have the closesocket function. */ +#define HAVE_CLOSESOCKET + +/* Define to 1 if you have the CloseSocket camel case function. */ +/* #undef HAVE_CLOSESOCKET_CAMEL */ + +/* Define to 1 if you have the connect function. */ +#define HAVE_CONNECT + +/* define if the compiler supports basic C++11 syntax */ +/* #undef HAVE_CXX11 */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H + +/* Define to 1 if you have the fcntl function. */ +/* #undef HAVE_FCNTL */ + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +/* #undef HAVE_FCNTL_O_NONBLOCK */ + +/* Define to 1 if you have the freeaddrinfo function. */ +#define HAVE_FREEADDRINFO + +/* Define to 1 if you have a working getaddrinfo function. */ +#define HAVE_GETADDRINFO + +/* Define to 1 if the getaddrinfo function is threadsafe. */ +#define HAVE_GETADDRINFO_THREADSAFE + +/* Define to 1 if you have the getenv function. */ +#define HAVE_GETENV + +/* Define to 1 if you have the gethostbyaddr function. */ +#define HAVE_GETHOSTBYADDR + +/* Define to 1 if you have the gethostbyname function. */ +#define HAVE_GETHOSTBYNAME + +/* Define to 1 if you have the gethostname function. */ +#define HAVE_GETHOSTNAME + +/* Define to 1 if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO + +/* Define to 1 if you have the getservbyport_r function. */ +/* #undef HAVE_GETSERVBYPORT_R */ + +/* Define to 1 if you have the `gettimeofday' function. */ +/* #undef HAVE_GETTIMEOFDAY */ + +/* Define to 1 if you have the `if_indextoname' function. */ +/* #undef HAVE_IF_INDEXTONAME */ + +/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ +/* #undef HAVE_INET_NET_PTON */ + +/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +/* #undef HAVE_INET_NTOP */ + +/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +/* #undef HAVE_INET_PTON */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H + +/* Define to 1 if you have the ioctl function. */ +/* #undef HAVE_IOCTL */ + +/* Define to 1 if you have the ioctlsocket function. */ +#define HAVE_IOCTLSOCKET + +/* Define to 1 if you have the IoctlSocket camel case function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL */ + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. + */ +/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ + +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +#define HAVE_IOCTLSOCKET_FIONBIO + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +/* #undef HAVE_IOCTL_FIONBIO */ + +/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ +/* #undef HAVE_IOCTL_SIOCGIFADDR */ + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H + +/* if your compiler supports LL */ +#define HAVE_LL + +/* Define to 1 if the compiler supports the 'long long' data type. */ +#define HAVE_LONGLONG + +/* Define to 1 if you have the malloc.h header file. */ +#define HAVE_MALLOC_H + +/* Define to 1 if you have the memory.h header file. */ +#define HAVE_MEMORY_H + +/* Define to 1 if you have the MSG_NOSIGNAL flag. */ +/* #undef HAVE_MSG_NOSIGNAL */ + +/* Define to 1 if you have the <netdb.h> header file. */ +/* #undef HAVE_NETDB_H */ + +/* Define to 1 if you have the <netinet/in.h> header file. */ +/* #undef HAVE_NETINET_IN_H */ + +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +/* #undef HAVE_NETINET_TCP_H */ + +/* Define to 1 if you have the <net/if.h> header file. */ +/* #undef HAVE_NET_IF_H */ + +/* Define to 1 if you have PF_INET6. */ +#define HAVE_PF_INET6 + +/* Define to 1 if you have the recv function. */ +#define HAVE_RECV + +/* Define to 1 if you have the recvfrom function. */ +#define HAVE_RECVFROM + +/* Define to 1 if you have the send function. */ +#define HAVE_SEND + +/* Define to 1 if you have the setsockopt function. */ +#define HAVE_SETSOCKOPT + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ + +/* Define to 1 if you have the <signal.h> header file. */ +#define HAVE_SIGNAL_H + +/* Define to 1 if sig_atomic_t is an available typedef. */ +#define HAVE_SIG_ATOMIC_T + +/* Define to 1 if sig_atomic_t is already defined as volatile. */ +/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */ + +/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ +#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID + +/* Define to 1 if you have the socket function. */ +#define HAVE_SOCKET + +/* Define to 1 if you have the <socket.h> header file. */ +/* #undef HAVE_SOCKET_H */ + +/* Define to 1 if you have the <stdbool.h> header file. */ +#define HAVE_STDBOOL_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H + +/* Define to 1 if you have the strcasecmp function. */ +/* #undef HAVE_STRCASECMP */ + +/* Define to 1 if you have the strcmpi function. */ +#define HAVE_STRCMPI + +/* Define to 1 if you have the strdup function. */ +#define HAVE_STRDUP + +/* Define to 1 if you have the stricmp function. */ +#define HAVE_STRICMP + +/* Define to 1 if you have the <strings.h> header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H + +/* Define to 1 if you have the strncasecmp function. */ +/* #undef HAVE_STRNCASECMP */ + +/* Define to 1 if you have the strncmpi function. */ +/* #undef HAVE_STRNCMPI */ + +/* Define to 1 if you have the strnicmp function. */ +#define HAVE_STRNICMP + +/* Define to 1 if you have the <stropts.h> header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if you have struct addrinfo. */ +#define HAVE_STRUCT_ADDRINFO + +/* Define to 1 if you have struct in6_addr. */ +#define HAVE_STRUCT_IN6_ADDR + +/* Define to 1 if you have struct sockaddr_in6. */ +#define HAVE_STRUCT_SOCKADDR_IN6 + +/* if struct sockaddr_storage is defined */ +#define HAVE_STRUCT_SOCKADDR_STORAGE + +/* Define to 1 if you have the timeval struct. */ +#define HAVE_STRUCT_TIMEVAL + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the <sys/param.h> header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define to 1 if you have the <sys/select.h> header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the <sys/socket.h> header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/time.h> header file. */ +/* #undef HAVE_SYS_TIME_H */ + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <sys/uio.h> header file. */ +/* #undef HAVE_SYS_UIO_H */ + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H + +/* Define to 1 if you have the <unistd.h> header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define to 1 if you have the windows.h header file. */ +#define HAVE_WINDOWS_H + +/* Define to 1 if you have the winsock2.h header file. */ +#define HAVE_WINSOCK2_H + +/* Define to 1 if you have the winsock.h header file. */ +#define HAVE_WINSOCK_H + +/* Define to 1 if you have the writev function. */ +/* #undef HAVE_WRITEV */ + +/* Define to 1 if you have the ws2tcpip.h header file. */ +#define HAVE_WS2TCPIP_H + +/* Define to 1 if you need the malloc.h header file even with stdlib.h */ +/* #undef NEED_MALLOC_H */ + +/* Define to 1 if you need the memory.h header file even with stdlib.h */ +/* #undef NEED_MEMORY_H */ + +/* a suitable file/device to read random data from */ +/* #undef RANDOM_FILE */ + +/* Define to the type qualifier pointed by arg 5 for recvfrom. */ +#define RECVFROM_QUAL_ARG5 + +/* Define to the type of arg 1 for recvfrom. */ +#define RECVFROM_TYPE_ARG1 SOCKET + +/* Define to the type pointed by arg 2 for recvfrom. */ +#define RECVFROM_TYPE_ARG2 void * + +/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ +#define RECVFROM_TYPE_ARG2_IS_VOID 0 + +/* Define to the type of arg 3 for recvfrom. */ +#define RECVFROM_TYPE_ARG3 int + +/* Define to the type of arg 4 for recvfrom. */ +#define RECVFROM_TYPE_ARG4 int + +/* Define to the type pointed by arg 5 for recvfrom. */ +#define RECVFROM_TYPE_ARG5 struct sockaddr * + +/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ +#define RECVFROM_TYPE_ARG5_IS_VOID 0 + +/* Define to the type pointed by arg 6 for recvfrom. */ +#define RECVFROM_TYPE_ARG6 socklen_t * + +/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ +#define RECVFROM_TYPE_ARG6_IS_VOID 0 + +/* Define to the function return type for recvfrom. */ +#define RECVFROM_TYPE_RETV int + +/* Define to the type of arg 1 for recv. */ +#define RECV_TYPE_ARG1 SOCKET + +/* Define to the type of arg 2 for recv. */ +#define RECV_TYPE_ARG2 void * + +/* Define to the type of arg 3 for recv. */ +#define RECV_TYPE_ARG3 int + +/* Define to the type of arg 4 for recv. */ +#define RECV_TYPE_ARG4 int + +/* Define to the function return type for recv. */ +#define RECV_TYPE_RETV int + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE + +/* Define to the type qualifier of arg 2 for send. */ +#define SEND_QUAL_ARG2 + +/* Define to the type of arg 1 for send. */ +#define SEND_TYPE_ARG1 SOCKET + +/* Define to the type of arg 2 for send. */ +#define SEND_TYPE_ARG2 void * + +/* Define to the type of arg 3 for send. */ +#define SEND_TYPE_ARG3 int + +/* Define to the type of arg 4 for send. */ +#define SEND_TYPE_ARG4 int + +/* Define to the function return type for send. */ +#define SEND_TYPE_RETV int + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +/* #undef TIME_WITH_SYS_TIME */ + +/* Define to disable non-blocking sockets. */ +#undef USE_BLOCKING_SOCKETS + +/* Define to avoid automatic inclusion of winsock.h */ +#undef WIN32_LEAN_AND_MEAN + +/* Type to use in place of in_addr_t when system does not provide it. */ +#undef in_addr_t + diff --git a/src/python/grpcio_tests/tests/unit/_junkdrawer/__init__.py b/tools/BUILD index 5fb4f3c3cf..e0f2a80bb4 100644 --- a/src/python/grpcio_tests/tests/unit/_junkdrawer/__init__.py +++ b/tools/BUILD @@ -1,4 +1,4 @@ -# Copyright 2015 gRPC authors. +# Copyright 2017 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,3 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +exports_files([ + "lsan_suppressions.txt", + "tsan_suppressions.txt", + "ubsan_suppressions.txt", +]) diff --git a/tools/distrib/pylint_code.sh b/tools/distrib/pylint_code.sh index 013b6660eb..82a818cce5 100755 --- a/tools/distrib/pylint_code.sh +++ b/tools/distrib/pylint_code.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2017 gRPC authors. +# Copyright 2017 The gRPC Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,14 +35,15 @@ python -m virtualenv $VIRTUALENV PYTHON=$VIRTUALENV/bin/python $PYTHON -m pip install --upgrade pip==10.0.1 -$PYTHON -m pip install pylint==1.6.5 +$PYTHON -m pip install pylint==1.9.2 +EXIT=0 for dir in "${DIRS[@]}"; do - $PYTHON -m pylint --rcfile=.pylintrc -rn "$dir" || exit $? + $PYTHON -m pylint --rcfile=.pylintrc -rn "$dir" || EXIT=1 done for dir in "${TEST_DIRS[@]}"; do - $PYTHON -m pylint --rcfile=.pylintrc-tests -rn "$dir" || exit $? + $PYTHON -m pylint --rcfile=.pylintrc-tests -rn "$dir" || EXIT=1 done -exit 0 +exit $EXIT diff --git a/tools/distrib/run_clang_tidy.py b/tools/distrib/run_clang_tidy.py index 337e6b43c8..7ad1c160ba 100755 --- a/tools/distrib/run_clang_tidy.py +++ b/tools/distrib/run_clang_tidy.py @@ -24,12 +24,6 @@ sys.path.append( os.path.dirname(sys.argv[0]), '..', 'run_tests', 'python_utils')) import jobset -GRPC_CHECKS = [ - 'modernize-use-nullptr', - 'google-build-namespaces', - 'google-build-explicit-make-pair', -] - extra_args = [ '-x', 'c++', @@ -57,8 +51,6 @@ args = argp.parse_args() cmdline = [ clang_tidy, - '--checks=-*,%s' % ','.join(GRPC_CHECKS), - '--warnings-as-errors=%s' % ','.join(GRPC_CHECKS) ] + ['--extra-arg-before=%s' % arg for arg in extra_args] if args.fix: diff --git a/tools/dockerfile/distribtest/csharp_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_centos7_x64/Dockerfile index 088635b0ea..3e1faafdc0 100644 --- a/tools/dockerfile/distribtest/csharp_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_centos7_x64/Dockerfile @@ -14,21 +14,11 @@ FROM centos:7 -RUN rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" -RUN yum-config-manager --add-repo http://download.mono-project.com/repo/centos/ +RUN rpm --import "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" +RUN curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo -RUN yum install -y mono +RUN yum install -y mono-devel -RUN yum install -y unzip - -# --nogpgcheck because nuget-2.12 package is not signed. -RUN yum install -y nuget --nogpgcheck +RUN yum install -y nuget -# Help mono correctly locate libMonoPosixHelper.so -# as a workaround for issue https://bugzilla.xamarin.com/show_bug.cgi?id=42820 -# The error message you'll get without this workaround: -# ``` -# WARNING: /usr/lib/libMonoPosixHelper.so -# WARNING: Unable to read package from path 'Grpc.1.1.0-dev.nupkg'. -# ``` -RUN cp /usr/lib64/libMonoPosixHelper.so /usr/lib/ +RUN yum install -y unzip diff --git a/tools/dockerfile/distribtest/csharp_jessie_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_jessie_x64/Dockerfile index 02ec4c278a..03fb7a5343 100644 --- a/tools/dockerfile/distribtest/csharp_jessie_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_jessie_x64/Dockerfile @@ -14,14 +14,13 @@ FROM debian:jessie +RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean + RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb http://download.mono-project.com/repo/debian jessie main" | tee /etc/apt/sources.list.d/mono-official.list -RUN echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list -RUN echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list +RUN echo "deb https://download.mono-project.com/repo/debian stable-jessie main" | tee /etc/apt/sources.list.d/mono-official-stable.list RUN apt-get update && apt-get install -y \ mono-devel \ - ca-certificates-mono \ nuget \ && apt-get clean diff --git a/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile index 758f314572..f2fa61a691 100644 --- a/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile @@ -14,14 +14,13 @@ FROM 32bit/debian:jessie +RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean + RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb http://download.mono-project.com/repo/debian jessie main" | tee /etc/apt/sources.list.d/mono-official.list -RUN echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list -RUN echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list +RUN echo "deb https://download.mono-project.com/repo/debian stable-jessie main" | tee /etc/apt/sources.list.d/mono-official-stable.list RUN apt-get update && apt-get install -y \ mono-devel \ - ca-certificates-mono \ nuget \ && apt-get clean diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile index 10279c5925..3edc31e170 100644 --- a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile @@ -14,15 +14,17 @@ FROM ubuntu:14.04 -RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list +RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | tee /etc/apt/sources.list.d/mono-official-stable.list RUN apt-get update && apt-get install -y \ mono-devel \ - ca-certificates-mono \ - nuget + nuget \ + && apt-get clean -RUN apt-get update && apt-get install -y unzip +RUN apt-get update && apt-get install -y unzip && apt-get clean # Install dotnet CLI RUN apt-get install -y apt-transport-https diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile index 0f40f18e38..1a58f9784b 100644 --- a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile @@ -14,19 +14,14 @@ FROM ubuntu:16.04 +RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | tee /etc/apt/sources.list.d/mono-official-stable.list + RUN apt-get update && apt-get install -y \ mono-devel \ - ca-certificates-mono \ nuget \ && apt-get clean -# make sure we have nuget 2.12+ (in case there's an older cached docker image) -RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list -RUN apt-get update && apt-get install -y nuget && apt-get clean - -# Prevent "Error: SendFailure (Error writing headers)" when fetching nuget packages -# See https://github.com/tianon/docker-brew-ubuntu-core/issues/86 -RUN apt-get update && apt-get install -y tzdata && apt-get clean - RUN apt-get update && apt-get install -y unzip && apt-get clean diff --git a/tools/dockerfile/distribtest/csharp_wheezy_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_wheezy_x64/Dockerfile deleted file mode 100644 index fb9c82c92b..0000000000 --- a/tools/dockerfile/distribtest/csharp_wheezy_x64/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM mono:4.4.2.11 - -# make sure we have nuget 2.12+ (in case there's an older cached docker image) -RUN apt-get update && apt-get install -y nuget - -RUN apt-get update && apt-get install -y unzip diff --git a/tools/dockerfile/interoptest/grpc_interop_python/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_python/build_interop.sh index a8898f85fa..7917e1cd60 100755 --- a/tools/dockerfile/interoptest/grpc_interop_python/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_python/build_interop.sh @@ -28,4 +28,5 @@ cp -r /var/local/jenkins/service_account $HOME || true cd /var/local/git/grpc -tools/run_tests/run_tests.py -l python -c opt --build_only +# interop tests only run using python2.7 currently (and python build is slow) +tools/run_tests/run_tests.py -l python --compiler python2.7 -c opt --build_only diff --git a/tools/internal_ci/linux/grpc_tsan_on_foundry.sh b/tools/internal_ci/linux/grpc_tsan_on_foundry.sh index fafa1ceecb..cd4e354be6 100644 --- a/tools/internal_ci/linux/grpc_tsan_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_tsan_on_foundry.sh @@ -14,5 +14,5 @@ # limitations under the License. export UPLOAD_TEST_RESULTS=true -EXTRA_FLAGS="--copt=-gmlt --strip=never --copt=-fsanitize=thread --linkopt=-fsanitize=thread --test_timeout=3600" +EXTRA_FLAGS="--copt=-gmlt --strip=never --copt=-fsanitize=thread --linkopt=-fsanitize=thread --test_timeout=3600 --action_env=TSAN_OPTIONS=suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1" github/grpc/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh "${EXTRA_FLAGS}" diff --git a/tools/profiling/ios_bin/binary_diff.py b/tools/profiling/ios_bin/binary_diff.py new file mode 100755 index 0000000000..6d5ae65e46 --- /dev/null +++ b/tools/profiling/ios_bin/binary_diff.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python2.7 +# +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import glob +import multiprocessing +import os +import shutil +import subprocess +import sys +from parse_link_map import parse_link_map + +sys.path.append( + os.path.join( + os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils')) +import comment_on_pr + +size_labels = ('Core', 'ObjC', 'BoringSSL', 'Protobuf', 'Total') + +argp = argparse.ArgumentParser( + description='Binary size diff of gRPC Objective-C sample') + +argp.add_argument( + '-d', + '--diff_base', + type=str, + help='Commit or branch to compare the current one to') + +args = argp.parse_args() + + +def dir_size(dir): + total = 0 + for dirpath, dirnames, filenames in os.walk(dir): + for f in filenames: + fp = os.path.join(dirpath, f) + total += os.stat(fp).st_size + return total + + +def get_size(where, frameworks): + build_dir = 'src/objective-c/examples/Sample/Build-%s/' % where + if not frameworks: + link_map_filename = 'Build/Intermediates.noindex/Sample.build/Release-iphoneos/Sample.build/Sample-LinkMap-normal-arm64.txt' + return parse_link_map(build_dir + link_map_filename) + else: + framework_dir = 'Build/Products/Release-iphoneos/Sample.app/Frameworks/' + boringssl_size = dir_size( + build_dir + framework_dir + 'openssl.framework') + core_size = dir_size(build_dir + framework_dir + 'grpc.framework') + objc_size = dir_size(build_dir + framework_dir + 'GRPCClient.framework') + \ + dir_size(build_dir + framework_dir + 'RxLibrary.framework') + \ + dir_size(build_dir + framework_dir + 'ProtoRPC.framework') + protobuf_size = dir_size( + build_dir + framework_dir + 'Protobuf.framework') + app_size = dir_size( + build_dir + 'Build/Products/Release-iphoneos/Sample.app') + return core_size, objc_size, boringssl_size, protobuf_size, app_size + + +def build(where, frameworks): + shutil.rmtree( + 'src/objective-c/examples/Sample/Build-%s' % where, ignore_errors=True) + subprocess.check_call( + 'CONFIG=opt EXAMPLE_PATH=src/objective-c/examples/Sample SCHEME=Sample FRAMEWORKS=%s ./build_one_example.sh' + % ('YES' if frameworks else 'NO'), + shell=True, + cwd='src/objective-c/tests') + os.rename('src/objective-c/examples/Sample/Build', + 'src/objective-c/examples/Sample/Build-%s' % where) + + +text = '' +for frameworks in [False, True]: + build('new', frameworks) + new_size = get_size('new', frameworks) + old_size = None + + if args.diff_base: + old = 'old' + where_am_i = subprocess.check_output( + ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip() + subprocess.check_call(['git', 'checkout', '--', '.']) + subprocess.check_call(['git', 'checkout', args.diff_base]) + subprocess.check_call(['git', 'submodule', 'update']) + try: + build('old', frameworks) + old_size = get_size('old', frameworks) + finally: + subprocess.check_call(['git', 'checkout', '--', '.']) + subprocess.check_call(['git', 'checkout', where_am_i]) + subprocess.check_call(['git', 'submodule', 'update']) + + text += ('****************FRAMEWORKS*****************\n' + if frameworks else '******************STATIC*******************\n') + row_format = "{:>10}{:>15}{:>15}" + '\n' + text += row_format.format('New size', '', 'Old size') + for i in range(0, len(size_labels)): + if old_size == None: + diff_sign = ' ' + elif new_size[i] == old_size[i]: + diff_sign = ' (=)' + elif new_size[i] > old_size[i]: + diff_sign = ' (>)' + else: + diff_sign = ' (<)' + text += ('\n' if i == len(size_labels) - 1 else '') + row_format.format( + '{:,}'.format(new_size[i]), size_labels[i] + diff_sign, + '{:,}'.format(old_size[i]) if old_size != None else '') + text += '\n' + +print text + +comment_on_pr.comment_on_pr('```\n%s\n```' % text) diff --git a/tools/profiling/ios_bin/parse_link_map.py b/tools/profiling/ios_bin/parse_link_map.py new file mode 100755 index 0000000000..eaa1d6e060 --- /dev/null +++ b/tools/profiling/ios_bin/parse_link_map.py @@ -0,0 +1,104 @@ +#!/usr/bin/python +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script analyzes link map file generated by Xcode. It calculates and +# prints out the sizes of each dependent library and the total sizes of the +# symbols. +# The script takes one parameter, which is the path to the link map file. + +import sys +import re + + +def parse_link_map(filename): + table_tag = {} + state = "start" + + table_stats_symbol = {} + table_stats_dead = {} + section_total_size = 0 + symbol_total_size = 0 + + boringssl_size = 0 + core_size = 0 + objc_size = 0 + protobuf_size = 0 + + lines = list(open(filename)) + for line in lines: + line_stripped = line[:-1] + if "# Object files:" == line_stripped: + state = "object" + continue + elif "# Sections:" == line_stripped: + state = "section" + continue + elif "# Symbols:" == line_stripped: + state = "symbol" + continue + elif "# Dead Stripped Symbols:" == line_stripped: + state = "dead" + continue + + if state == "object": + segs = re.search('(\[ *[0-9]*\]) (.*)', line_stripped) + table_tag[segs.group(1)] = segs.group(2) + + if state == "section": + if len(line_stripped) == 0 or line_stripped[0] == '#': + continue + segs = re.search('^(.+?)\s+(.+?)\s+.*', line_stripped) + section_total_size += int(segs.group(2), 16) + + if state == "symbol": + if len(line_stripped) == 0 or line_stripped[0] == '#': + continue + segs = re.search('^.+?\s+(.+?)\s+(\[.+?\]).*', line_stripped) + target = table_tag[segs.group(2)] + target_stripped = re.search('^(.*?)(\(.+?\))?$', target).group(1) + size = int(segs.group(1), 16) + if not target_stripped in table_stats_symbol: + table_stats_symbol[target_stripped] = 0 + table_stats_symbol[target_stripped] += size + if 'BoringSSL' in target_stripped: + boringssl_size += size + elif 'libgRPC-Core' in target_stripped: + core_size += size + elif 'libgRPC-RxLibrary' in target_stripped or \ + 'libgRPC' in target_stripped or \ + 'libgRPC-ProtoLibrary' in target_stripped: + objc_size += size + elif 'libProtobuf' in target_stripped: + protobuf_size += size + + for target in table_stats_symbol: + symbol_total_size += table_stats_symbol[target] + + return core_size, objc_size, boringssl_size, protobuf_size, symbol_total_size + + +def main(): + filename = sys.argv[1] + core_size, objc_size, boringssl_size, protobuf_size, total_size = parse_link_map( + filename) + print('Core size:{:,}'.format(core_size)) + print('ObjC size:{:,}'.format(objc_size)) + print('BoringSSL size:{:,}'.format(boringssl_size)) + print('Protobuf size:{:,}\n'.format(protobuf_size)) + print('Total size:{:,}'.format(total_size)) + + +if __name__ == "__main__": + main() diff --git a/tools/run_tests/artifacts/build_artifact_csharp.bat b/tools/run_tests/artifacts/build_artifact_csharp.bat index a84bc54157..ac2c92b716 100644 --- a/tools/run_tests/artifacts/build_artifact_csharp.bat +++ b/tools/run_tests/artifacts/build_artifact_csharp.bat @@ -19,11 +19,12 @@ set GRPC_SKIP_DOTNET_RESTORE=true @call tools\run_tests\helper_scripts\pre_build_csharp.bat %ARCHITECTURE% || goto :error cd cmake\build\%ARCHITECTURE% -cmake --build . --target grpc_csharp_ext --config Release +cmake --build . --target grpc_csharp_ext --config RelWithDebInfo cd ..\..\.. mkdir -p %ARTIFACTS_OUT% -copy /Y cmake\build\Win32\Release\grpc_csharp_ext.dll %ARTIFACTS_OUT% || copy /Y cmake\build\x64\Release\grpc_csharp_ext.dll %ARTIFACTS_OUT% || goto :error +copy /Y cmake\build\Win32\RelWithDebInfo\grpc_csharp_ext.dll %ARTIFACTS_OUT% || copy /Y cmake\build\x64\RelWithDebInfo\grpc_csharp_ext.dll %ARTIFACTS_OUT% || goto :error +copy /Y cmake\build\Win32\RelWithDebInfo\grpc_csharp_ext.pdb %ARTIFACTS_OUT% || copy /Y cmake\build\x64\RelWithDebInfo\grpc_csharp_ext.pdb %ARTIFACTS_OUT% || goto :error goto :EOF diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 213325439e..e02f4bffcd 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -303,7 +303,6 @@ def targets(): CppDistribTest('linux', 'x64', 'jessie', 'cmake_as_submodule'), CppDistribTest('windows', 'x86', testcase='cmake'), CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'), - CSharpDistribTest('linux', 'x64', 'wheezy'), CSharpDistribTest('linux', 'x64', 'jessie'), CSharpDistribTest('linux', 'x86', 'jessie'), CSharpDistribTest('linux', 'x64', 'centos7'), diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 564f39b6ca..291cf87244 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6567,6 +6567,26 @@ "gpr", "gpr_test_util", "grpc", + "grpc++", + "grpc++_test_config", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "cancel_ares_query_test", + "src": [ + "test/cpp/naming/cancel_ares_query_test.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", "grpc_test_util" ], "headers": [], @@ -8768,6 +8788,7 @@ "test/core/end2end/tests/max_message_length.cc", "test/core/end2end/tests/negative_deadline.cc", "test/core/end2end/tests/network_status_change.cc", + "test/core/end2end/tests/no_error_on_hotpath.cc", "test/core/end2end/tests/no_logging.cc", "test/core/end2end/tests/no_op.cc", "test/core/end2end/tests/payload.cc", @@ -8868,6 +8889,7 @@ "test/core/end2end/tests/max_message_length.cc", "test/core/end2end/tests/negative_deadline.cc", "test/core/end2end/tests/network_status_change.cc", + "test/core/end2end/tests/no_error_on_hotpath.cc", "test/core/end2end/tests/no_logging.cc", "test/core/end2end/tests/no_op.cc", "test/core/end2end/tests/payload.cc", @@ -9773,6 +9795,32 @@ { "deps": [ "gpr", + "gpr_base_headers", + "grpc_base_headers" + ], + "headers": [ + "src/core/lib/iomgr/cfstream_handle.h", + "src/core/lib/iomgr/endpoint_cfstream.h", + "src/core/lib/iomgr/error_cfstream.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_cfstream", + "src": [ + "src/core/lib/iomgr/cfstream_handle.cc", + "src/core/lib/iomgr/cfstream_handle.h", + "src/core/lib/iomgr/endpoint_cfstream.cc", + "src/core/lib/iomgr/endpoint_cfstream.h", + "src/core/lib/iomgr/error_cfstream.cc", + "src/core/lib/iomgr/error_cfstream.h", + "src/core/lib/iomgr/tcp_client_cfstream.cc" + ], + "third_party": false, + "type": "filegroup" + }, + { + "deps": [ + "gpr", "grpc_base" ], "headers": [ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 83d4f32eb6..48031c2fd3 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -82,7 +82,7 @@ "posix", "windows" ], - "cpu_cost": 1.0, + "cpu_cost": 10, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, @@ -5664,6 +5664,28 @@ }, { "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "cancel_ares_query_test", + "platforms": [ + "linux", + "mac", + "posix" + ], + "uses_polling": true + }, + { + "args": [], "boringssl": true, "ci_platforms": [ "linux", @@ -7845,6 +7867,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_census_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -9620,6 +9665,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_compress_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -11335,6 +11403,28 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_fakesec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -12928,6 +13018,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_fd_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -14289,6 +14402,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -15912,6 +16048,25 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_full+pipe_test", + "platforms": [ + "linux" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -17504,6 +17659,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+trace_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_op" ], "ci_platforms": [ @@ -19256,6 +19434,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+workarounds_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -21064,6 +21265,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_http_proxy_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -22903,6 +23128,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_load_reporting_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -24711,6 +24959,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_oauth2_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -27615,6 +27887,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -28863,6 +29159,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair+trace_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_op" ], "ci_platforms": [ @@ -30149,6 +30469,32 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [ + "msan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_1byte_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -31550,6 +31896,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_ssl_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -34475,6 +34844,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -35970,6 +36362,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "inproc_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -37193,6 +37608,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_census_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -38945,6 +39383,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_compress_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -40532,6 +40993,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_fd_nosec_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -41870,6 +42354,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -43474,6 +43981,25 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_full+pipe_nosec_test", + "platforms": [ + "linux" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -45043,6 +45569,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+trace_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_op" ], "ci_platforms": [ @@ -46772,6 +47321,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+workarounds_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -48556,6 +49128,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_http_proxy_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -50372,6 +50968,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_load_reporting_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -53188,6 +53807,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -54412,6 +55055,30 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair+trace_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_op" ], "ci_platforms": [ @@ -55672,6 +56339,32 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [ + "msan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_1byte_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -57000,6 +57693,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_nosec_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ @@ -58472,6 +59188,29 @@ }, { "args": [ + "no_error_on_hotpath" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "inproc_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ "no_logging" ], "ci_platforms": [ diff --git a/tools/run_tests/python_utils/upload_rbe_results.py b/tools/run_tests/python_utils/upload_rbe_results.py index 5955b3792f..7236227f7c 100644 --- a/tools/run_tests/python_utils/upload_rbe_results.py +++ b/tools/run_tests/python_utils/upload_rbe_results.py @@ -125,7 +125,7 @@ def _get_resultstore_data(api_key, invocation_id): if __name__ == "__main__": - # Arguments are necessary if running in a non-Kokoro envrionment. + # Arguments are necessary if running in a non-Kokoro environment. argp = argparse.ArgumentParser(description='Upload RBE results.') argp.add_argument('--api_key', default='', type=str) argp.add_argument('--invocation_id', default='', type=str) @@ -175,8 +175,8 @@ if __name__ == "__main__": 'build_id': os.getenv('KOKORO_BUILD_NUMBER'), 'build_url': - 'https://sponge.corp.google.com/invocation?id=%s' % - os.getenv('KOKORO_BUILD_ID'), + 'https://source.cloud.google.com/results/invocations/%s' % + invocation_id, 'test_target': action['id']['targetId'], 'test_case': diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py index 09dcd57ad4..cbb4c32a2a 100644 --- a/tools/run_tests/python_utils/upload_test_results.py +++ b/tools/run_tests/python_utils/upload_test_results.py @@ -86,6 +86,26 @@ def _get_build_metadata(test_results): test_results['job_name'] = job_name +def _insert_rows_with_retries(bq, bq_table, bq_rows): + """Insert rows to bq table. Retry on error.""" + # BigQuery sometimes fails with large uploads, so batch 1,000 rows at a time. + for i in range((len(bq_rows) / 1000) + 1): + max_retries = 3 + for attempt in range(max_retries): + if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, + bq_table, + bq_rows[i * 1000:(i + 1) * 1000]): + break + else: + if attempt < max_retries - 1: + print('Error uploading result to bigquery, will retry.') + else: + print( + 'Error uploading result to bigquery, all attempts failed.' + ) + sys.exit(1) + + def upload_results_to_bq(resultset, bq_table, args, platform): """Upload test results to a BQ table. @@ -106,6 +126,7 @@ def upload_results_to_bq(resultset, bq_table, args, platform): partition_type=_PARTITION_TYPE, expiration_ms=_EXPIRATION_MS) + bq_rows = [] for shortname, results in six.iteritems(resultset): for result in results: test_results = {} @@ -124,23 +145,9 @@ def upload_results_to_bq(resultset, bq_table, args, platform): test_results['return_code'] = result.returncode test_results['test_name'] = shortname test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S') - row = big_query_utils.make_row(str(uuid.uuid4()), test_results) - - # TODO(jtattermusch): rows are inserted one by one, very inefficient - max_retries = 3 - for attempt in range(max_retries): - if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, - bq_table, [row]): - break - else: - if attempt < max_retries - 1: - print('Error uploading result to bigquery, will retry.') - else: - print( - 'Error uploading result to bigquery, all attempts failed.' - ) - sys.exit(1) + bq_rows.append(row) + _insert_rows_with_retries(bq, bq_table, bq_rows) def upload_interop_results_to_bq(resultset, bq_table, args): @@ -162,6 +169,7 @@ def upload_interop_results_to_bq(resultset, bq_table, args): partition_type=_PARTITION_TYPE, expiration_ms=_EXPIRATION_MS) + bq_rows = [] for shortname, results in six.iteritems(resultset): for result in results: test_results = {} @@ -175,17 +183,5 @@ def upload_interop_results_to_bq(resultset, bq_table, args): test_results['test_case'] = shortname.split(':')[3] test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S') row = big_query_utils.make_row(str(uuid.uuid4()), test_results) - # TODO(jtattermusch): rows are inserted one by one, very inefficient - max_retries = 3 - for attempt in range(max_retries): - if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, - bq_table, [row]): - break - else: - if attempt < max_retries - 1: - print('Error uploading result to bigquery, will retry.') - else: - print( - 'Error uploading result to bigquery, all attempts failed.' - ) - sys.exit(1) + bq_rows.append(row) + _insert_rows_with_retries(bq, bq_table, bq_rows) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 014fb7d33a..e04b13b24c 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1114,6 +1114,12 @@ class ObjCLanguage(object): 'SCHEME': 'SwiftSample', 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' }), + self.config.job_spec( + ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + timeout_seconds=10 * 60, + shortname='cfstream-tests', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS), ] def pre_build_steps(self): @@ -1126,7 +1132,10 @@ class ObjCLanguage(object): return [] def build_steps(self): - return [['src/objective-c/tests/build_tests.sh']] + return [ + ['src/objective-c/tests/build_tests.sh'], + ['test/core/iomgr/ios/CFStreamTests/build_tests.sh'], + ] def post_tests_steps(self): return [] diff --git a/tools/run_tests/sanity/check_channel_arg_usage.py b/tools/run_tests/sanity/check_channel_arg_usage.py new file mode 100755 index 0000000000..bb9f9299c1 --- /dev/null +++ b/tools/run_tests/sanity/check_channel_arg_usage.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import print_function + +import os +import sys + +os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) + +# set of files that are allowed to use the raw GRPC_ARG_* types +_EXCEPTIONS = set([ + 'src/core/lib/channel/channel_args.cc', + 'src/core/lib/channel/channel_args.h', +]) + +_BANNED = set([ + "GRPC_ARG_POINTER", + "GRPC_ARG_STRING", + "GRPC_ARG_INTEGER", +]) + +errors = 0 +num_files = 0 +for root, dirs, files in os.walk('src/core'): + for filename in files: + num_files += 1 + path = os.path.join(root, filename) + if path in _EXCEPTIONS: continue + with open(path) as f: + text = f.read() + for banned in _BANNED: + if banned in text: + print('Illegal use of "%s" in %s' % (banned, path)) + errors += 1 + +assert errors == 0 +# This check comes about from this issue: +# https://github.com/grpc/grpc/issues/15381 +# Basically, a change rendered this script useless and we did not realize it. +# This dumb check ensures that this type of issue doesn't occur again. +assert num_files > 300 # we definitely have more than 300 files diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index 1d3f2eba8a..8afd826453 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -30,7 +30,8 @@ BANNED_EXCEPT = { ['src/core/lib/slice/slice_buffer.cc'], 'grpc_slice_ref(': ['src/core/lib/slice/slice.cc'], 'grpc_slice_unref(': ['src/core/lib/slice/slice.cc'], - 'grpc_error_create(': ['src/core/lib/iomgr/error.cc'], + 'grpc_error_create(': + ['src/core/lib/iomgr/error.cc', 'src/core/lib/iomgr/error_cfstream.cc'], 'grpc_error_ref(': ['src/core/lib/iomgr/error.cc'], 'grpc_error_unref(': ['src/core/lib/iomgr/error.cc'], 'grpc_os_error(': ['src/core/lib/iomgr/error.cc'], |