From 2b226adf60eac113e6c2780aa551c775e72511d6 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 11 Jan 2018 16:11:35 -0800 Subject: Remove alarm from core, implement in C++ layer only --- BUILD | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'BUILD') diff --git a/BUILD b/BUILD index 6ed4a5a0ae..cd70722fc5 100644 --- a/BUILD +++ b/BUILD @@ -117,6 +117,7 @@ GRPCXX_SRCS = [ "src/cpp/client/create_channel_posix.cc", "src/cpp/client/credentials_cc.cc", "src/cpp/client/generic_stub.cc", + "src/cpp/common/alarm.cc", "src/cpp/common/channel_arguments.cc", "src/cpp/common/channel_filter.cc", "src/cpp/common/completion_queue_cc.cc", @@ -721,7 +722,6 @@ grpc_cc_library( "src/core/lib/slice/slice_hash_table.cc", "src/core/lib/slice/slice_intern.cc", "src/core/lib/slice/slice_string_helpers.cc", - "src/core/lib/surface/alarm.cc", "src/core/lib/surface/api_trace.cc", "src/core/lib/surface/byte_buffer.cc", "src/core/lib/surface/byte_buffer_reader.cc", @@ -845,7 +845,6 @@ grpc_cc_library( "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.h", - "src/core/lib/surface/alarm_internal.h", "src/core/lib/surface/api_trace.h", "src/core/lib/surface/call.h", "src/core/lib/surface/call_test_only.h", -- cgit v1.2.3 From 392e2131e17bd2a028d5b91b7a99aee26bbfbf19 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Sat, 13 Jan 2018 23:58:26 -0800 Subject: Removing grpc_alarm from core requires a major version bump for core --- BUILD | 2 +- Makefile | 40 ++++++++++++++++++------------------ build.yaml | 4 ++-- build_config.rb | 2 +- src/core/lib/surface/version.cc | 4 ++-- src/objective-c/tests/version.h | 2 +- tools/doxygen/Doxyfile.core | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) (limited to 'BUILD') diff --git a/BUILD b/BUILD index cd70722fc5..08aac4160e 100644 --- a/BUILD +++ b/BUILD @@ -56,7 +56,7 @@ config_setting( # This should be updated along with build.yaml g_stands_for = "glamorous" -core_version = "5.0.0-dev" +core_version = "6.0.0-dev" version = "1.10.0-dev" diff --git a/Makefile b/Makefile index 540c8c86d8..eec1154005 100644 --- a/Makefile +++ b/Makefile @@ -418,7 +418,7 @@ E = @echo Q = @ endif -CORE_VERSION = 5.0.0-dev +CORE_VERSION = 6.0.0-dev CPP_VERSION = 1.10.0-dev CSHARP_VERSION = 1.10.0-dev @@ -468,7 +468,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -5 +SHARED_VERSION_CORE = -6 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -1 else ifeq ($(SYSTEM),Darwin) @@ -2686,7 +2686,7 @@ install-shared_c: shared_c strip-shared_c install-pkg-config_c ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgpr.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.5 + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.6 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2695,7 +2695,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2704,7 +2704,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2713,7 +2713,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so endif ifneq ($(SYSTEM),MINGW32) @@ -2730,7 +2730,7 @@ install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-con ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2739,7 +2739,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2748,7 +2748,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_error_details$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_error_details.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_error_details.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_error_details.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_error_details.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2757,7 +2757,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_reflection.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2766,7 +2766,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so endif ifneq ($(SYSTEM),MINGW32) @@ -2783,7 +2783,7 @@ install-shared_csharp: shared_csharp strip-shared_csharp ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a $(prefix)/lib/libgrpc_csharp_ext.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.5 + $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so endif ifneq ($(SYSTEM),MINGW32) @@ -2948,8 +2948,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.5 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.5 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.6 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.6 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -3310,8 +3310,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.5 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.5 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.6 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -3611,8 +3611,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.5 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.5 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.6 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif endif @@ -4418,8 +4418,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.5 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.5 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.6 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.6 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif diff --git a/build.yaml b/build.yaml index 588263e646..66ce7cc8fa 100644 --- a/build.yaml +++ b/build.yaml @@ -12,8 +12,8 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 5.0.0-dev - g_stands_for: glamorous + core_version: 6.0.0-dev + g_stands_for: glossy version: 1.10.0-dev filegroups: - name: census diff --git a/build_config.rb b/build_config.rb index 3dc31d4ce3..644c80fdb6 100644 --- a/build_config.rb +++ b/build_config.rb @@ -13,5 +13,5 @@ # limitations under the License. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-5.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-6.dll' end diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 19498a6df7..153b6e0297 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -21,6 +21,6 @@ #include -const char* grpc_version_string(void) { return "5.0.0-dev"; } +const char* grpc_version_string(void) { return "6.0.0-dev"; } -const char* grpc_g_stands_for(void) { return "glamorous"; } +const char* grpc_g_stands_for(void) { return "glossy"; } diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index d8581b9779..5140aa23a6 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -24,4 +24,4 @@ #define GRPC_OBJC_VERSION_STRING @"1.10.0-dev" -#define GRPC_C_VERSION_STRING @"5.0.0-dev" +#define GRPC_C_VERSION_STRING @"6.0.0-dev" diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 916d3b1e49..3d42772e84 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 5.0.0-dev +PROJECT_NUMBER = 6.0.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 861ef5b669..a112412006 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 5.0.0-dev +PROJECT_NUMBER = 6.0.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 8a99fdb57e564f2166f5f83e50baa4c47e9a3f8d Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 25 Jan 2018 15:38:20 -0800 Subject: Move cmdline and subprocess from public gpr to test/core/util --- BUILD | 5 - CMakeLists.txt | 78 ++-- Makefile | 113 +++-- build.yaml | 37 +- config.m4 | 3 - config.w32 | 3 - gRPC-C++.podspec | 2 + gRPC-Core.podspec | 10 +- grpc.def | 14 - grpc.gemspec | 5 - grpc.gyp | 9 +- include/grpc/module.modulemap | 2 - include/grpc/support/cmdline.h | 88 ---- include/grpc/support/subprocess.h | 44 -- package.xml | 5 - src/core/lib/gpr/cmdline.cc | 330 -------------- src/core/lib/gpr/subprocess_posix.cc | 99 ----- src/core/lib/gpr/subprocess_windows.cc | 126 ------ src/python/grpcio/grpc_core_dependencies.py | 3 - src/ruby/ext/grpc/rb_grpc_imports.generated.c | 28 -- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 44 -- test/core/bad_ssl/bad_ssl_test.cc | 2 +- test/core/bad_ssl/server_common.cc | 2 +- test/core/fling/client.cc | 2 +- test/core/fling/fling_stream_test.cc | 3 +- test/core/fling/fling_test.cc | 3 +- test/core/fling/server.cc | 2 +- test/core/gpr/BUILD | 10 - test/core/gpr/cmdline_test.cc | 491 --------------------- test/core/http/httpcli_test.cc | 3 +- test/core/http/httpscli_test.cc | 3 +- test/core/json/json_rewrite.cc | 2 +- test/core/memory_usage/client.cc | 3 +- test/core/memory_usage/memory_usage_test.cc | 3 +- test/core/memory_usage/server.cc | 2 +- .../core/network_benchmarks/low_level_ping_pong.cc | 2 +- test/core/security/BUILD | 3 + test/core/security/create_jwt.cc | 3 +- test/core/security/fetch_oauth2.cc | 2 +- .../security/print_google_default_creds_token.cc | 2 +- test/core/security/verify_jwt.cc | 2 +- test/core/surface/public_headers_must_be_c89.c | 16 - test/core/util/BUILD | 15 + test/core/util/cmdline.cc | 330 ++++++++++++++ test/core/util/cmdline.h | 88 ++++ test/core/util/cmdline_test.cc | 491 +++++++++++++++++++++ test/core/util/subprocess.h | 44 ++ test/core/util/subprocess_posix.cc | 99 +++++ test/core/util/subprocess_windows.cc | 126 ++++++ test/cpp/util/BUILD | 2 + test/cpp/util/subprocess.cc | 2 +- tools/doxygen/Doxyfile.c++ | 2 - tools/doxygen/Doxyfile.c++.internal | 2 - tools/doxygen/Doxyfile.core | 2 - tools/doxygen/Doxyfile.core.internal | 5 - tools/run_tests/generated/sources_and_headers.json | 61 +-- tools/run_tests/generated/tests.json | 48 +- 57 files changed, 1413 insertions(+), 1513 deletions(-) delete mode 100644 include/grpc/support/cmdline.h delete mode 100644 include/grpc/support/subprocess.h delete mode 100644 src/core/lib/gpr/cmdline.cc delete mode 100644 src/core/lib/gpr/subprocess_posix.cc delete mode 100644 src/core/lib/gpr/subprocess_windows.cc delete mode 100644 test/core/gpr/cmdline_test.cc create mode 100644 test/core/util/cmdline.cc create mode 100644 test/core/util/cmdline.h create mode 100644 test/core/util/cmdline_test.cc create mode 100644 test/core/util/subprocess.h create mode 100644 test/core/util/subprocess_posix.cc create mode 100644 test/core/util/subprocess_windows.cc (limited to 'BUILD') diff --git a/BUILD b/BUILD index 0a8be79e8a..1086d3fd47 100644 --- a/BUILD +++ b/BUILD @@ -67,14 +67,12 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", "include/grpc/support/avl.h", - "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", - "include/grpc/support/subprocess.h", "include/grpc/support/sync.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", @@ -458,7 +456,6 @@ grpc_cc_library( "src/core/lib/gpr/arena.cc", "src/core/lib/gpr/atm.cc", "src/core/lib/gpr/avl.cc", - "src/core/lib/gpr/cmdline.cc", "src/core/lib/gpr/cpu_iphone.cc", "src/core/lib/gpr/cpu_linux.cc", "src/core/lib/gpr/cpu_posix.cc", @@ -479,8 +476,6 @@ grpc_cc_library( "src/core/lib/gpr/string_posix.cc", "src/core/lib/gpr/string_util_windows.cc", "src/core/lib/gpr/string_windows.cc", - "src/core/lib/gpr/subprocess_posix.cc", - "src/core/lib/gpr/subprocess_windows.cc", "src/core/lib/gpr/sync.cc", "src/core/lib/gpr/sync_posix.cc", "src/core/lib/gpr/sync_windows.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index c557e9469a..7678eee093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,7 @@ add_dependencies(buildtests_c channel_create_test) add_dependencies(buildtests_c chttp2_hpack_encoder_test) add_dependencies(buildtests_c chttp2_stream_map_test) add_dependencies(buildtests_c chttp2_varint_test) +add_dependencies(buildtests_c cmdline_test) add_dependencies(buildtests_c combiner_test) add_dependencies(buildtests_c compression_test) add_dependencies(buildtests_c concurrent_connectivity_test) @@ -258,7 +259,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c goaway_server_test) endif() add_dependencies(buildtests_c gpr_avl_test) -add_dependencies(buildtests_c gpr_cmdline_test) add_dependencies(buildtests_c gpr_cpu_test) add_dependencies(buildtests_c gpr_env_test) add_dependencies(buildtests_c gpr_host_port_test) @@ -628,7 +628,6 @@ add_library(gpr src/core/lib/gpr/arena.cc src/core/lib/gpr/atm.cc src/core/lib/gpr/avl.cc - src/core/lib/gpr/cmdline.cc src/core/lib/gpr/cpu_iphone.cc src/core/lib/gpr/cpu_linux.cc src/core/lib/gpr/cpu_posix.cc @@ -649,8 +648,6 @@ add_library(gpr src/core/lib/gpr/string_posix.cc src/core/lib/gpr/string_util_windows.cc src/core/lib/gpr/string_windows.cc - src/core/lib/gpr/subprocess_posix.cc - src/core/lib/gpr/subprocess_windows.cc src/core/lib/gpr/sync.cc src/core/lib/gpr/sync_posix.cc src/core/lib/gpr/sync_windows.cc @@ -704,14 +701,12 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/avl.h - include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h include/grpc/support/string_util.h - include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h @@ -1448,6 +1443,7 @@ add_library(grpc_test_util test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc + test/core/util/cmdline.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc @@ -1459,6 +1455,8 @@ add_library(grpc_test_util test/core/util/port_isolated_runtime_environment.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc + test/core/util/subprocess_posix.cc + test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/core/util/trickle_endpoint.cc src/core/lib/backoff/backoff.cc @@ -1717,6 +1715,7 @@ add_library(grpc_test_util_unsecure test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc + test/core/util/cmdline.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc @@ -1728,6 +1727,8 @@ add_library(grpc_test_util_unsecure test/core/util/port_isolated_runtime_environment.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc + test/core/util/subprocess_posix.cc + test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/core/util/trickle_endpoint.cc src/core/lib/backoff/backoff.cc @@ -2498,14 +2499,12 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/avl.h - include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h include/grpc/support/string_util.h - include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h @@ -2982,14 +2981,12 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/avl.h - include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h include/grpc/support/string_util.h - include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h @@ -3712,14 +3709,12 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/avl.h - include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h include/grpc/support/string_util.h - include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h @@ -5123,6 +5118,32 @@ target_link_libraries(chttp2_varint_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(cmdline_test + test/core/util/cmdline_test.cc +) + + +target_include_directories(cmdline_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} +) + +target_link_libraries(cmdline_test + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr + gpr_test_util + grpc_test_util +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(combiner_test test/core/iomgr/combiner_test.cc ) @@ -5677,31 +5698,6 @@ target_link_libraries(gpr_avl_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(gpr_cmdline_test - test/core/gpr/cmdline_test.cc -) - - -target_include_directories(gpr_cmdline_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} -) - -target_link_libraries(gpr_cmdline_test - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(gpr_cpu_test test/core/gpr/cpu_test.cc ) @@ -6261,7 +6257,9 @@ target_include_directories(grpc_create_jwt target_link_libraries(grpc_create_jwt ${_gRPC_SSL_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util grpc + gpr_test_util gpr ) @@ -6430,7 +6428,9 @@ target_include_directories(grpc_print_google_default_creds_token target_link_libraries(grpc_print_google_default_creds_token ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util grpc + gpr_test_util gpr ) @@ -6516,7 +6516,9 @@ target_include_directories(grpc_verify_jwt target_link_libraries(grpc_verify_jwt ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util grpc + gpr_test_util gpr ) @@ -6886,7 +6888,9 @@ target_include_directories(json_rewrite target_link_libraries(json_rewrite ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util grpc + gpr_test_util gpr ) diff --git a/Makefile b/Makefile index 39a94d8c55..a8f10fd2fa 100644 --- a/Makefile +++ b/Makefile @@ -966,6 +966,7 @@ chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test chttp2_stream_map_test: $(BINDIR)/$(CONFIG)/chttp2_stream_map_test chttp2_varint_test: $(BINDIR)/$(CONFIG)/chttp2_varint_test client_fuzzer: $(BINDIR)/$(CONFIG)/client_fuzzer +cmdline_test: $(BINDIR)/$(CONFIG)/cmdline_test combiner_test: $(BINDIR)/$(CONFIG)/combiner_test compression_test: $(BINDIR)/$(CONFIG)/compression_test concurrent_connectivity_test: $(BINDIR)/$(CONFIG)/concurrent_connectivity_test @@ -986,7 +987,6 @@ fling_stream_test: $(BINDIR)/$(CONFIG)/fling_stream_test fling_test: $(BINDIR)/$(CONFIG)/fling_test goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test -gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test @@ -1369,6 +1369,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \ $(BINDIR)/$(CONFIG)/chttp2_stream_map_test \ $(BINDIR)/$(CONFIG)/chttp2_varint_test \ + $(BINDIR)/$(CONFIG)/cmdline_test \ $(BINDIR)/$(CONFIG)/combiner_test \ $(BINDIR)/$(CONFIG)/compression_test \ $(BINDIR)/$(CONFIG)/concurrent_connectivity_test \ @@ -1389,7 +1390,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/fling_test \ $(BINDIR)/$(CONFIG)/goaway_server_test \ $(BINDIR)/$(CONFIG)/gpr_avl_test \ - $(BINDIR)/$(CONFIG)/gpr_cmdline_test \ $(BINDIR)/$(CONFIG)/gpr_cpu_test \ $(BINDIR)/$(CONFIG)/gpr_env_test \ $(BINDIR)/$(CONFIG)/gpr_host_port_test \ @@ -1806,6 +1806,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/chttp2_stream_map_test || ( echo test chttp2_stream_map_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_varint_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_varint_test || ( echo test chttp2_varint_test failed ; exit 1 ) + $(E) "[RUN] Testing cmdline_test" + $(Q) $(BINDIR)/$(CONFIG)/cmdline_test || ( echo test cmdline_test failed ; exit 1 ) $(E) "[RUN] Testing combiner_test" $(Q) $(BINDIR)/$(CONFIG)/combiner_test || ( echo test combiner_test failed ; exit 1 ) $(E) "[RUN] Testing compression_test" @@ -1842,8 +1844,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/goaway_server_test || ( echo test goaway_server_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_avl_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_avl_test || ( echo test gpr_avl_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_cmdline_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_cmdline_test || ( echo test gpr_cmdline_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_cpu_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_cpu_test || ( echo test gpr_cpu_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_env_test" @@ -2849,7 +2849,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/atm.cc \ src/core/lib/gpr/avl.cc \ - src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ src/core/lib/gpr/cpu_posix.cc \ @@ -2870,8 +2869,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ - src/core/lib/gpr/subprocess_posix.cc \ - src/core/lib/gpr/subprocess_windows.cc \ src/core/lib/gpr/sync.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ @@ -2897,14 +2894,12 @@ PUBLIC_HEADERS_C += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ - include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ - include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ @@ -3653,6 +3648,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ + test/core/util/cmdline.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ @@ -3664,6 +3660,8 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_isolated_runtime_environment.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ + test/core/util/subprocess_posix.cc \ + test/core/util/subprocess_windows.cc \ test/core/util/tracer_util.cc \ test/core/util/trickle_endpoint.cc \ src/core/lib/backoff/backoff.cc \ @@ -3915,6 +3913,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ + test/core/util/cmdline.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ @@ -3926,6 +3925,8 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/port_isolated_runtime_environment.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ + test/core/util/subprocess_posix.cc \ + test/core/util/subprocess_windows.cc \ test/core/util/tracer_util.cc \ test/core/util/trickle_endpoint.cc \ src/core/lib/backoff/backoff.cc \ @@ -4629,14 +4630,12 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ - include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ - include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ @@ -5118,14 +5117,12 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ - include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ - include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ @@ -5837,14 +5834,12 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ - include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ - include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ @@ -9267,6 +9262,38 @@ endif endif +CMDLINE_TEST_SRC = \ + test/core/util/cmdline_test.cc \ + +CMDLINE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CMDLINE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/cmdline_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/cmdline_test: $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/cmdline_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/util/cmdline_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a + +deps_cmdline_test: $(CMDLINE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CMDLINE_TEST_OBJS:.o=.dep) +endif +endif + + COMBINER_TEST_SRC = \ test/core/iomgr/combiner_test.cc \ @@ -9910,38 +9937,6 @@ endif endif -GPR_CMDLINE_TEST_SRC = \ - test/core/gpr/cmdline_test.cc \ - -GPR_CMDLINE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_CMDLINE_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gpr_cmdline_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gpr_cmdline_test: $(GPR_CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_cmdline_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gpr/cmdline_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_gpr_cmdline_test: $(GPR_CMDLINE_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GPR_CMDLINE_TEST_OBJS:.o=.dep) -endif -endif - - GPR_CPU_TEST_SRC = \ test/core/gpr/cpu_test.cc \ @@ -10628,14 +10623,14 @@ else -$(BINDIR)/$(CONFIG)/grpc_create_jwt: $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/grpc_create_jwt: $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt + $(Q) $(LD) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt endif -$(OBJDIR)/$(CONFIG)/test/core/security/create_jwt.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/security/create_jwt.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_grpc_create_jwt: $(GRPC_CREATE_JWT_OBJS:.o=.dep) @@ -10820,14 +10815,14 @@ else -$(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token: $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token: $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token + $(Q) $(LD) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token endif -$(OBJDIR)/$(CONFIG)/test/core/security/print_google_default_creds_token.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/security/print_google_default_creds_token.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_grpc_print_google_default_creds_token: $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS:.o=.dep) @@ -10916,14 +10911,14 @@ else -$(BINDIR)/$(CONFIG)/grpc_verify_jwt: $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/grpc_verify_jwt: $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt + $(Q) $(LD) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt endif -$(OBJDIR)/$(CONFIG)/test/core/security/verify_jwt.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/security/verify_jwt.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_grpc_verify_jwt: $(GRPC_VERIFY_JWT_OBJS:.o=.dep) @@ -11466,14 +11461,14 @@ else -$(BINDIR)/$(CONFIG)/json_rewrite: $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/json_rewrite: $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite + $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite endif -$(OBJDIR)/$(CONFIG)/test/core/json/json_rewrite.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/json/json_rewrite.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_json_rewrite: $(JSON_REWRITE_OBJS:.o=.dep) diff --git a/build.yaml b/build.yaml index d4d5af1371..3564d465fb 100644 --- a/build.yaml +++ b/build.yaml @@ -30,7 +30,6 @@ filegroups: - src/core/lib/gpr/arena.cc - src/core/lib/gpr/atm.cc - src/core/lib/gpr/avl.cc - - src/core/lib/gpr/cmdline.cc - src/core/lib/gpr/cpu_iphone.cc - src/core/lib/gpr/cpu_linux.cc - src/core/lib/gpr/cpu_posix.cc @@ -51,8 +50,6 @@ filegroups: - src/core/lib/gpr/string_posix.cc - src/core/lib/gpr/string_util_windows.cc - src/core/lib/gpr/string_windows.cc - - src/core/lib/gpr/subprocess_posix.cc - - src/core/lib/gpr/subprocess_windows.cc - src/core/lib/gpr/sync.cc - src/core/lib/gpr/sync_posix.cc - src/core/lib/gpr/sync_windows.cc @@ -80,14 +77,12 @@ filegroups: - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - include/grpc/support/avl.h - - include/grpc/support/cmdline.h - include/grpc/support/cpu.h - include/grpc/support/host_port.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h - include/grpc/support/string_util.h - - include/grpc/support/subprocess.h - include/grpc/support/sync.h - include/grpc/support/sync_custom.h - include/grpc/support/sync_generic.h @@ -715,6 +710,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.h - test/core/end2end/fixtures/proxy.h - test/core/iomgr/endpoint_tests.h + - test/core/util/cmdline.h - test/core/util/debugger_macros.h - test/core/util/grpc_profiler.h - test/core/util/histogram.h @@ -725,6 +721,7 @@ filegroups: - test/core/util/port.h - test/core/util/port_server_client.h - test/core/util/slice_splitter.h + - test/core/util/subprocess.h - test/core/util/tracer_util.h - test/core/util/trickle_endpoint.h src: @@ -733,6 +730,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.cc - test/core/end2end/fixtures/proxy.cc - test/core/iomgr/endpoint_tests.cc + - test/core/util/cmdline.cc - test/core/util/debugger_macros.cc - test/core/util/grpc_profiler.cc - test/core/util/histogram.cc @@ -744,6 +742,8 @@ filegroups: - test/core/util/port_isolated_runtime_environment.cc - test/core/util/port_server_client.cc - test/core/util/slice_splitter.cc + - test/core/util/subprocess_posix.cc + - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/core/util/trickle_endpoint.cc deps: @@ -1881,6 +1881,16 @@ targets: - test/core/end2end/fuzzers/client_fuzzer_corpus dict: test/core/end2end/fuzzers/hpack.dictionary maxlen: 2048 +- name: cmdline_test + build: test + language: c + src: + - test/core/util/cmdline_test.cc + deps: + - gpr + - gpr_test_util + - grpc_test_util + uses_polling: false - name: combiner_test cpu_cost: 10 build: test @@ -2141,15 +2151,6 @@ targets: - gpr_test_util - gpr uses_polling: false -- name: gpr_cmdline_test - build: test - language: c - src: - - test/core/gpr/cmdline_test.cc - deps: - - gpr_test_util - - gpr - uses_polling: false - name: gpr_cpu_test cpu_cost: 30 build: test @@ -2366,7 +2367,9 @@ targets: src: - test/core/security/create_jwt.cc deps: + - grpc_test_util - grpc + - gpr_test_util - gpr secure: true uses_polling: false @@ -2434,7 +2437,9 @@ targets: src: - test/core/security/print_google_default_creds_token.cc deps: + - grpc_test_util - grpc + - gpr_test_util - gpr uses_polling: false - name: grpc_security_connector_test @@ -2463,7 +2468,9 @@ targets: src: - test/core/security/verify_jwt.cc deps: + - grpc_test_util - grpc + - gpr_test_util - gpr uses_polling: false - name: handshake_client @@ -2679,7 +2686,9 @@ targets: src: - test/core/json/json_rewrite.cc deps: + - grpc_test_util - grpc + - gpr_test_util - gpr uses_polling: false - name: json_rewrite_test diff --git a/config.m4 b/config.m4 index 9fc624d880..774cf1bcc3 100644 --- a/config.m4 +++ b/config.m4 @@ -43,7 +43,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/arena.cc \ src/core/lib/gpr/atm.cc \ src/core/lib/gpr/avl.cc \ - src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ src/core/lib/gpr/cpu_posix.cc \ @@ -64,8 +63,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ - src/core/lib/gpr/subprocess_posix.cc \ - src/core/lib/gpr/subprocess_windows.cc \ src/core/lib/gpr/sync.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ diff --git a/config.w32 b/config.w32 index bb9a17da33..e3fc4a66a1 100644 --- a/config.w32 +++ b/config.w32 @@ -20,7 +20,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\arena.cc " + "src\\core\\lib\\gpr\\atm.cc " + "src\\core\\lib\\gpr\\avl.cc " + - "src\\core\\lib\\gpr\\cmdline.cc " + "src\\core\\lib\\gpr\\cpu_iphone.cc " + "src\\core\\lib\\gpr\\cpu_linux.cc " + "src\\core\\lib\\gpr\\cpu_posix.cc " + @@ -41,8 +40,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\string_posix.cc " + "src\\core\\lib\\gpr\\string_util_windows.cc " + "src\\core\\lib\\gpr\\string_windows.cc " + - "src\\core\\lib\\gpr\\subprocess_posix.cc " + - "src\\core\\lib\\gpr\\subprocess_windows.cc " + "src\\core\\lib\\gpr\\sync.cc " + "src\\core\\lib\\gpr\\sync_posix.cc " + "src\\core\\lib\\gpr\\sync_windows.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 55f33d9aef..5236cda02e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -618,6 +618,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.h', 'test/core/end2end/fixtures/proxy.h', 'test/core/iomgr/endpoint_tests.h', + 'test/core/util/cmdline.h', 'test/core/util/debugger_macros.h', 'test/core/util/grpc_profiler.h', 'test/core/util/histogram.h', @@ -628,6 +629,7 @@ Pod::Spec.new do |s| 'test/core/util/port.h', 'test/core/util/port_server_client.h', 'test/core/util/slice_splitter.h', + 'test/core/util/subprocess.h', 'test/core/util/tracer_util.h', 'test/core/util/trickle_endpoint.h', 'src/core/ext/filters/client_channel/backup_poller.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7ee7bb52d2..23a01010d0 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -115,14 +115,12 @@ Pod::Spec.new do |s| 'include/grpc/support/atm_gcc_sync.h', 'include/grpc/support/atm_windows.h', 'include/grpc/support/avl.h', - 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', 'include/grpc/support/host_port.h', 'include/grpc/support/log.h', 'include/grpc/support/log_windows.h', 'include/grpc/support/port_platform.h', 'include/grpc/support/string_util.h', - 'include/grpc/support/subprocess.h', 'include/grpc/support/sync.h', 'include/grpc/support/sync_custom.h', 'include/grpc/support/sync_generic.h', @@ -215,7 +213,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', 'src/core/lib/gpr/avl.cc', - 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', 'src/core/lib/gpr/cpu_posix.cc', @@ -236,8 +233,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', 'src/core/lib/gpr/string_windows.cc', - 'src/core/lib/gpr/subprocess_posix.cc', - 'src/core/lib/gpr/subprocess_windows.cc', 'src/core/lib/gpr/sync.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', @@ -993,6 +988,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/cmdline.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -1004,6 +1000,8 @@ Pod::Spec.new do |s| 'test/core/util/port_isolated_runtime_environment.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', + 'test/core/util/subprocess_posix.cc', + 'test/core/util/subprocess_windows.cc', 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', 'test/core/end2end/data/ssl_test_data.h', @@ -1012,6 +1010,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.h', 'test/core/end2end/fixtures/proxy.h', 'test/core/iomgr/endpoint_tests.h', + 'test/core/util/cmdline.h', 'test/core/util/debugger_macros.h', 'test/core/util/grpc_profiler.h', 'test/core/util/histogram.h', @@ -1022,6 +1021,7 @@ Pod::Spec.new do |s| 'test/core/util/port.h', 'test/core/util/port_server_client.h', 'test/core/util/slice_splitter.h', + 'test/core/util/subprocess.h', 'test/core/util/tracer_util.h', 'test/core/util/trickle_endpoint.h', 'test/core/end2end/end2end_tests.cc', diff --git a/grpc.def b/grpc.def index 2bec47480a..28589b10f0 100644 --- a/grpc.def +++ b/grpc.def @@ -190,15 +190,6 @@ EXPORTS gpr_avl_get gpr_avl_maybe_get gpr_avl_is_empty - gpr_cmdline_create - gpr_cmdline_add_int - gpr_cmdline_add_flag - gpr_cmdline_add_string - gpr_cmdline_on_extra_arg - gpr_cmdline_set_survive_failure - gpr_cmdline_parse - gpr_cmdline_destroy - gpr_cmdline_usage_string gpr_cpu_num_cores gpr_cpu_current_cpu gpr_join_host_port @@ -212,11 +203,6 @@ EXPORTS gpr_format_message gpr_strdup gpr_asprintf - gpr_subprocess_binary_extension - gpr_subprocess_create - gpr_subprocess_destroy - gpr_subprocess_join - gpr_subprocess_interrupt gpr_mu_init gpr_mu_destroy gpr_mu_lock diff --git a/grpc.gemspec b/grpc.gemspec index 41e56d0bf1..86d6408c8c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -50,14 +50,12 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/atm_gcc_sync.h ) s.files += %w( include/grpc/support/atm_windows.h ) s.files += %w( include/grpc/support/avl.h ) - s.files += %w( include/grpc/support/cmdline.h ) s.files += %w( include/grpc/support/cpu.h ) s.files += %w( include/grpc/support/host_port.h ) s.files += %w( include/grpc/support/log.h ) s.files += %w( include/grpc/support/log_windows.h ) s.files += %w( include/grpc/support/port_platform.h ) s.files += %w( include/grpc/support/string_util.h ) - s.files += %w( include/grpc/support/subprocess.h ) s.files += %w( include/grpc/support/sync.h ) s.files += %w( include/grpc/support/sync_custom.h ) s.files += %w( include/grpc/support/sync_generic.h ) @@ -105,7 +103,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/arena.cc ) s.files += %w( src/core/lib/gpr/atm.cc ) s.files += %w( src/core/lib/gpr/avl.cc ) - s.files += %w( src/core/lib/gpr/cmdline.cc ) s.files += %w( src/core/lib/gpr/cpu_iphone.cc ) s.files += %w( src/core/lib/gpr/cpu_linux.cc ) s.files += %w( src/core/lib/gpr/cpu_posix.cc ) @@ -126,8 +123,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/string_posix.cc ) s.files += %w( src/core/lib/gpr/string_util_windows.cc ) s.files += %w( src/core/lib/gpr/string_windows.cc ) - s.files += %w( src/core/lib/gpr/subprocess_posix.cc ) - s.files += %w( src/core/lib/gpr/subprocess_windows.cc ) s.files += %w( src/core/lib/gpr/sync.cc ) s.files += %w( src/core/lib/gpr/sync_posix.cc ) s.files += %w( src/core/lib/gpr/sync_windows.cc ) diff --git a/grpc.gyp b/grpc.gyp index 7b1178f898..b394b5e32b 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -165,7 +165,6 @@ 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', 'src/core/lib/gpr/avl.cc', - 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', 'src/core/lib/gpr/cpu_posix.cc', @@ -186,8 +185,6 @@ 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', 'src/core/lib/gpr/string_windows.cc', - 'src/core/lib/gpr/subprocess_posix.cc', - 'src/core/lib/gpr/subprocess_windows.cc', 'src/core/lib/gpr/sync.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', @@ -508,6 +505,7 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/cmdline.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -519,6 +517,8 @@ 'test/core/util/port_isolated_runtime_environment.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', + 'test/core/util/subprocess_posix.cc', + 'test/core/util/subprocess_windows.cc', 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', 'src/core/lib/backoff/backoff.cc', @@ -722,6 +722,7 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/cmdline.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -733,6 +734,8 @@ 'test/core/util/port_isolated_runtime_environment.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', + 'test/core/util/subprocess_posix.cc', + 'test/core/util/subprocess_windows.cc', 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', 'src/core/lib/backoff/backoff.cc', diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index d23072f556..8f0cd46ae0 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -5,14 +5,12 @@ framework module grpc { header "support/alloc.h" header "support/atm.h" header "support/avl.h" - header "support/cmdline.h" header "support/cpu.h" header "support/host_port.h" header "support/log.h" header "support/log_windows.h" header "support/port_platform.h" header "support/string_util.h" - header "support/subprocess.h" header "support/sync.h" header "support/sync_generic.h" header "support/thd.h" diff --git a/include/grpc/support/cmdline.h b/include/grpc/support/cmdline.h deleted file mode 100644 index c34a109fbd..0000000000 --- a/include/grpc/support/cmdline.h +++ /dev/null @@ -1,88 +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. - * - */ - -#ifndef GRPC_SUPPORT_CMDLINE_H -#define GRPC_SUPPORT_CMDLINE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Simple command line parser. - - Supports flags that can be specified as -foo, --foo, --no-foo, -no-foo, etc - And integers, strings that can be specified as -foo=4, -foo blah, etc - - No support for short command line options (but we may get that in the - future.) - - Usage (for a program with a single flag argument 'foo'): - - int main(int argc, char **argv) { - gpr_cmdline *cl; - int verbose = 0; - - cl = gpr_cmdline_create("My cool tool"); - gpr_cmdline_add_int(cl, "verbose", "Produce verbose output?", &verbose); - gpr_cmdline_parse(cl, argc, argv); - gpr_cmdline_destroy(cl); - - if (verbose) { - gpr_log(GPR_INFO, "Goodbye cruel world!"); - } - - return 0; - } */ - -typedef struct gpr_cmdline gpr_cmdline; - -/** Construct a command line parser: takes a short description of the tool - doing the parsing */ -GPRAPI gpr_cmdline* gpr_cmdline_create(const char* description); -/** Add an integer parameter, with a name (used on the command line) and some - helpful text (used in the command usage) */ -GPRAPI void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, - const char* help, int* value); -/** The same, for a boolean flag */ -GPRAPI void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, - const char* help, int* value); -/** And for a string */ -GPRAPI void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, - const char* help, const char** value); -/** Set a callback for non-named arguments */ -GPRAPI void gpr_cmdline_on_extra_arg( - gpr_cmdline* cl, const char* name, const char* help, - void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); -/** Enable surviving failure: default behavior is to exit the process */ -GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline* cl); -/** Parse the command line; returns 1 on success, on failure either dies - (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been - called */ -GPRAPI int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv); -/** Destroy the parser */ -GPRAPI void gpr_cmdline_destroy(gpr_cmdline* cl); -/** Get a string describing usage */ -GPRAPI char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_CMDLINE_H */ diff --git a/include/grpc/support/subprocess.h b/include/grpc/support/subprocess.h deleted file mode 100644 index 175f7b50eb..0000000000 --- a/include/grpc/support/subprocess.h +++ /dev/null @@ -1,44 +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. - * - */ - -#ifndef GRPC_SUPPORT_SUBPROCESS_H -#define GRPC_SUPPORT_SUBPROCESS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct gpr_subprocess gpr_subprocess; - -/** .exe on windows, empty on unices */ -GPRAPI const char* gpr_subprocess_binary_extension(); - -GPRAPI gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); -/** if subprocess has not been joined, kill it */ -GPRAPI void gpr_subprocess_destroy(gpr_subprocess* p); -/** returns exit status; can be called at most once */ -GPRAPI int gpr_subprocess_join(gpr_subprocess* p); -GPRAPI void gpr_subprocess_interrupt(gpr_subprocess* p); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* GRPC_SUPPORT_SUBPROCESS_H */ diff --git a/package.xml b/package.xml index 3f529a2096..7a7858af65 100644 --- a/package.xml +++ b/package.xml @@ -57,14 +57,12 @@ - - @@ -112,7 +110,6 @@ - @@ -133,8 +130,6 @@ - - diff --git a/src/core/lib/gpr/cmdline.cc b/src/core/lib/gpr/cmdline.cc deleted file mode 100644 index 4118f9a72a..0000000000 --- a/src/core/lib/gpr/cmdline.cc +++ /dev/null @@ -1,330 +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. - * - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include "src/core/lib/gpr/string.h" - -typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype; - -typedef struct arg { - const char* name; - const char* help; - argtype type; - void* value; - struct arg* next; -} arg; - -struct gpr_cmdline { - const char* description; - arg* args; - const char* argv0; - - const char* extra_arg_name; - const char* extra_arg_help; - void (*extra_arg)(void* user_data, const char* arg); - void* extra_arg_user_data; - - int (*state)(gpr_cmdline* cl, char* arg); - arg* cur_arg; - - int survive_failure; -}; - -static int normal_state(gpr_cmdline* cl, char* arg); - -gpr_cmdline* gpr_cmdline_create(const char* description) { - gpr_cmdline* cl = (gpr_cmdline*)gpr_zalloc(sizeof(gpr_cmdline)); - - cl->description = description; - cl->state = normal_state; - - return cl; -} - -void gpr_cmdline_set_survive_failure(gpr_cmdline* cl) { - cl->survive_failure = 1; -} - -void gpr_cmdline_destroy(gpr_cmdline* cl) { - while (cl->args) { - arg* a = cl->args; - cl->args = a->next; - gpr_free(a); - } - gpr_free(cl); -} - -static void add_arg(gpr_cmdline* cl, const char* name, const char* help, - argtype type, void* value) { - arg* a; - - for (a = cl->args; a; a = a->next) { - GPR_ASSERT(0 != strcmp(a->name, name)); - } - - a = (arg*)gpr_zalloc(sizeof(arg)); - a->name = name; - a->help = help; - a->type = type; - a->value = value; - a->next = cl->args; - cl->args = a; -} - -void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, - int* value) { - add_arg(cl, name, help, ARGTYPE_INT, value); -} - -void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, - int* value) { - add_arg(cl, name, help, ARGTYPE_BOOL, value); -} - -void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, - const char** value) { - add_arg(cl, name, help, ARGTYPE_STRING, value); -} - -void gpr_cmdline_on_extra_arg( - gpr_cmdline* cl, const char* name, const char* help, - void (*on_extra_arg)(void* user_data, const char* arg), void* user_data) { - GPR_ASSERT(!cl->extra_arg); - GPR_ASSERT(on_extra_arg); - - cl->extra_arg = on_extra_arg; - cl->extra_arg_user_data = user_data; - cl->extra_arg_name = name; - cl->extra_arg_help = help; -} - -/* recursively descend argument list, adding the last element - to s first - so that arguments are added in the order they were - added to the list by api calls */ -static void add_args_to_usage(gpr_strvec* s, arg* a) { - char* tmp; - - if (!a) return; - add_args_to_usage(s, a->next); - - switch (a->type) { - case ARGTYPE_BOOL: - gpr_asprintf(&tmp, " [--%s|--no-%s]", a->name, a->name); - gpr_strvec_add(s, tmp); - break; - case ARGTYPE_STRING: - gpr_asprintf(&tmp, " [--%s=string]", a->name); - gpr_strvec_add(s, tmp); - break; - case ARGTYPE_INT: - gpr_asprintf(&tmp, " [--%s=int]", a->name); - gpr_strvec_add(s, tmp); - break; - } -} - -char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) { - /* TODO(ctiller): make this prettier */ - gpr_strvec s; - char* tmp; - const char* name = strrchr(argv0, '/'); - - if (name) { - name++; - } else { - name = argv0; - } - - gpr_strvec_init(&s); - - gpr_asprintf(&tmp, "Usage: %s", name); - gpr_strvec_add(&s, tmp); - add_args_to_usage(&s, cl->args); - if (cl->extra_arg) { - gpr_asprintf(&tmp, " [%s...]", cl->extra_arg_name); - gpr_strvec_add(&s, tmp); - } - gpr_strvec_add(&s, gpr_strdup("\n")); - - tmp = gpr_strvec_flatten(&s, nullptr); - gpr_strvec_destroy(&s); - return tmp; -} - -static int print_usage_and_die(gpr_cmdline* cl) { - char* usage = gpr_cmdline_usage_string(cl, cl->argv0); - fprintf(stderr, "%s", usage); - gpr_free(usage); - if (!cl->survive_failure) { - exit(1); - } - return 0; -} - -static int extra_state(gpr_cmdline* cl, char* str) { - if (!cl->extra_arg) { - return print_usage_and_die(cl); - } - cl->extra_arg(cl->extra_arg_user_data, str); - return 1; -} - -static arg* find_arg(gpr_cmdline* cl, char* name) { - arg* a; - - for (a = cl->args; a; a = a->next) { - if (0 == strcmp(a->name, name)) { - break; - } - } - - if (!a) { - fprintf(stderr, "Unknown argument: %s\n", name); - return nullptr; - } - - return a; -} - -static int value_state(gpr_cmdline* cl, char* str) { - long intval; - char* end; - - GPR_ASSERT(cl->cur_arg); - - switch (cl->cur_arg->type) { - case ARGTYPE_INT: - intval = strtol(str, &end, 0); - if (*end || intval < INT_MIN || intval > INT_MAX) { - fprintf(stderr, "expected integer, got '%s' for %s\n", str, - cl->cur_arg->name); - return print_usage_and_die(cl); - } - *(int*)cl->cur_arg->value = (int)intval; - break; - case ARGTYPE_BOOL: - if (0 == strcmp(str, "1") || 0 == strcmp(str, "true")) { - *(int*)cl->cur_arg->value = 1; - } else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) { - *(int*)cl->cur_arg->value = 0; - } else { - fprintf(stderr, "expected boolean, got '%s' for %s\n", str, - cl->cur_arg->name); - return print_usage_and_die(cl); - } - break; - case ARGTYPE_STRING: - *(char**)cl->cur_arg->value = str; - break; - } - - cl->state = normal_state; - return 1; -} - -static int normal_state(gpr_cmdline* cl, char* str) { - char* eq = nullptr; - char* tmp = nullptr; - char* arg_name = nullptr; - int r = 1; - - if (0 == strcmp(str, "-help") || 0 == strcmp(str, "--help") || - 0 == strcmp(str, "-h")) { - return print_usage_and_die(cl); - } - - cl->cur_arg = nullptr; - - if (str[0] == '-') { - if (str[1] == '-') { - if (str[2] == 0) { - /* handle '--' to move to just extra args */ - cl->state = extra_state; - return 1; - } - str += 2; - } else { - str += 1; - } - /* first byte of str is now past the leading '-' or '--' */ - if (str[0] == 'n' && str[1] == 'o' && str[2] == '-') { - /* str is of the form '--no-foo' - it's a flag disable */ - str += 3; - cl->cur_arg = find_arg(cl, str); - if (cl->cur_arg == nullptr) { - return print_usage_and_die(cl); - } - if (cl->cur_arg->type != ARGTYPE_BOOL) { - fprintf(stderr, "%s is not a flag argument\n", str); - return print_usage_and_die(cl); - } - *(int*)cl->cur_arg->value = 0; - return 1; /* early out */ - } - eq = strchr(str, '='); - if (eq != nullptr) { - /* copy the string into a temp buffer and extract the name */ - tmp = arg_name = (char*)gpr_malloc((size_t)(eq - str + 1)); - memcpy(arg_name, str, (size_t)(eq - str)); - arg_name[eq - str] = 0; - } else { - arg_name = str; - } - cl->cur_arg = find_arg(cl, arg_name); - if (cl->cur_arg == nullptr) { - return print_usage_and_die(cl); - } - if (eq != nullptr) { - /* str was of the type --foo=value, parse the value */ - r = value_state(cl, eq + 1); - } else if (cl->cur_arg->type != ARGTYPE_BOOL) { - /* flag types don't have a '--foo value' variant, other types do */ - cl->state = value_state; - } else { - /* flag parameter: just set the value */ - *(int*)cl->cur_arg->value = 1; - } - } else { - r = extra_state(cl, str); - } - - gpr_free(tmp); - return r; -} - -int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv) { - int i; - - GPR_ASSERT(argc >= 1); - cl->argv0 = argv[0]; - - for (i = 1; i < argc; i++) { - if (!cl->state(cl, argv[i])) { - return 0; - } - } - return 1; -} diff --git a/src/core/lib/gpr/subprocess_posix.cc b/src/core/lib/gpr/subprocess_posix.cc deleted file mode 100644 index dc046b6499..0000000000 --- a/src/core/lib/gpr/subprocess_posix.cc +++ /dev/null @@ -1,99 +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. - * - */ - -#include - -#ifdef GPR_POSIX_SUBPROCESS - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -struct gpr_subprocess { - int pid; - bool joined; -}; - -const char* gpr_subprocess_binary_extension() { return ""; } - -gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { - gpr_subprocess* r; - int pid; - char** exec_args; - - pid = fork(); - if (pid == -1) { - return nullptr; - } else if (pid == 0) { - exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*)); - memcpy(exec_args, argv, (size_t)argc * sizeof(char*)); - exec_args[argc] = nullptr; - execv(exec_args[0], exec_args); - /* if we reach here, an error has occurred */ - gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno)); - _exit(1); - return nullptr; - } else { - r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess)); - r->pid = pid; - return r; - } -} - -void gpr_subprocess_destroy(gpr_subprocess* p) { - if (!p->joined) { - kill(p->pid, SIGKILL); - gpr_subprocess_join(p); - } - gpr_free(p); -} - -int gpr_subprocess_join(gpr_subprocess* p) { - int status; -retry: - if (waitpid(p->pid, &status, 0) == -1) { - if (errno == EINTR) { - goto retry; - } - gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid, - strerror(errno)); - return -1; - } - p->joined = true; - return status; -} - -void gpr_subprocess_interrupt(gpr_subprocess* p) { - if (!p->joined) { - kill(p->pid, SIGINT); - } -} - -#endif /* GPR_POSIX_SUBPROCESS */ diff --git a/src/core/lib/gpr/subprocess_windows.cc b/src/core/lib/gpr/subprocess_windows.cc deleted file mode 100644 index 1947d475e3..0000000000 --- a/src/core/lib/gpr/subprocess_windows.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * 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 - -#ifdef GPR_WINDOWS_SUBPROCESS - -#include -#include -#include - -#include -#include -#include -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/string_windows.h" - -struct gpr_subprocess { - PROCESS_INFORMATION pi; - int joined; - int interrupted; -}; - -const char* gpr_subprocess_binary_extension() { return ".exe"; } - -gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { - gpr_subprocess* r; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - char* args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); - TCHAR* args_tchar; - - args_tchar = gpr_char_to_tchar(args); - gpr_free(args); - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - memset(&pi, 0, sizeof(pi)); - - if (!CreateProcess(NULL, args_tchar, NULL, NULL, FALSE, - CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { - gpr_free(args_tchar); - return NULL; - } - gpr_free(args_tchar); - - r = (gpr_subprocess*)gpr_malloc(sizeof(gpr_subprocess)); - memset(r, 0, sizeof(*r)); - r->pi = pi; - return r; -} - -void gpr_subprocess_destroy(gpr_subprocess* p) { - if (p) { - if (!p->joined) { - gpr_subprocess_interrupt(p); - gpr_subprocess_join(p); - } - if (p->pi.hProcess) { - CloseHandle(p->pi.hProcess); - } - if (p->pi.hThread) { - CloseHandle(p->pi.hThread); - } - gpr_free(p); - } -} - -int gpr_subprocess_join(gpr_subprocess* p) { - DWORD dwExitCode; - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - if (dwExitCode == STILL_ACTIVE) { - if (WaitForSingleObject(p->pi.hProcess, INFINITE) == WAIT_OBJECT_0) { - p->joined = 1; - goto getExitCode; - } - return -1; // failed to join - } else { - goto getExitCode; - } - } else { - return -1; // failed to get exit code - } - -getExitCode: - if (p->interrupted) { - return 0; - } - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - return (int)dwExitCode; - } else { - return -1; // failed to get exit code - } -} - -void gpr_subprocess_interrupt(gpr_subprocess* p) { - DWORD dwExitCode; - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - if (dwExitCode == STILL_ACTIVE) { - gpr_log(GPR_INFO, "sending ctrl-break"); - GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, p->pi.dwProcessId); - p->joined = 1; - p->interrupted = 1; - } - } - return; -} - -#endif /* GPR_WINDOWS_SUBPROCESS */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 86122f909c..d9ff181c6c 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -19,7 +19,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', 'src/core/lib/gpr/avl.cc', - 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', 'src/core/lib/gpr/cpu_posix.cc', @@ -40,8 +39,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', 'src/core/lib/gpr/string_windows.cc', - 'src/core/lib/gpr/subprocess_posix.cc', - 'src/core/lib/gpr/subprocess_windows.cc', 'src/core/lib/gpr/sync.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 5473c52bb5..d52468ae55 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -213,15 +213,6 @@ gpr_avl_remove_type gpr_avl_remove_import; gpr_avl_get_type gpr_avl_get_import; gpr_avl_maybe_get_type gpr_avl_maybe_get_import; gpr_avl_is_empty_type gpr_avl_is_empty_import; -gpr_cmdline_create_type gpr_cmdline_create_import; -gpr_cmdline_add_int_type gpr_cmdline_add_int_import; -gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; -gpr_cmdline_add_string_type gpr_cmdline_add_string_import; -gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; -gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; -gpr_cmdline_parse_type gpr_cmdline_parse_import; -gpr_cmdline_destroy_type gpr_cmdline_destroy_import; -gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; gpr_cpu_num_cores_type gpr_cpu_num_cores_import; gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; gpr_join_host_port_type gpr_join_host_port_import; @@ -235,11 +226,6 @@ gpr_set_log_function_type gpr_set_log_function_import; gpr_format_message_type gpr_format_message_import; gpr_strdup_type gpr_strdup_import; gpr_asprintf_type gpr_asprintf_import; -gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; -gpr_subprocess_create_type gpr_subprocess_create_import; -gpr_subprocess_destroy_type gpr_subprocess_destroy_import; -gpr_subprocess_join_type gpr_subprocess_join_import; -gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; gpr_mu_init_type gpr_mu_init_import; gpr_mu_destroy_type gpr_mu_destroy_import; gpr_mu_lock_type gpr_mu_lock_import; @@ -486,15 +472,6 @@ void grpc_rb_load_imports(HMODULE library) { gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get"); gpr_avl_maybe_get_import = (gpr_avl_maybe_get_type) GetProcAddress(library, "gpr_avl_maybe_get"); gpr_avl_is_empty_import = (gpr_avl_is_empty_type) GetProcAddress(library, "gpr_avl_is_empty"); - gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create"); - gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int"); - gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag"); - gpr_cmdline_add_string_import = (gpr_cmdline_add_string_type) GetProcAddress(library, "gpr_cmdline_add_string"); - gpr_cmdline_on_extra_arg_import = (gpr_cmdline_on_extra_arg_type) GetProcAddress(library, "gpr_cmdline_on_extra_arg"); - gpr_cmdline_set_survive_failure_import = (gpr_cmdline_set_survive_failure_type) GetProcAddress(library, "gpr_cmdline_set_survive_failure"); - gpr_cmdline_parse_import = (gpr_cmdline_parse_type) GetProcAddress(library, "gpr_cmdline_parse"); - gpr_cmdline_destroy_import = (gpr_cmdline_destroy_type) GetProcAddress(library, "gpr_cmdline_destroy"); - gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string"); gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port"); @@ -508,11 +485,6 @@ void grpc_rb_load_imports(HMODULE library) { gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf"); - gpr_subprocess_binary_extension_import = (gpr_subprocess_binary_extension_type) GetProcAddress(library, "gpr_subprocess_binary_extension"); - gpr_subprocess_create_import = (gpr_subprocess_create_type) GetProcAddress(library, "gpr_subprocess_create"); - gpr_subprocess_destroy_import = (gpr_subprocess_destroy_type) GetProcAddress(library, "gpr_subprocess_destroy"); - gpr_subprocess_join_import = (gpr_subprocess_join_type) GetProcAddress(library, "gpr_subprocess_join"); - gpr_subprocess_interrupt_import = (gpr_subprocess_interrupt_type) GetProcAddress(library, "gpr_subprocess_interrupt"); gpr_mu_init_import = (gpr_mu_init_type) GetProcAddress(library, "gpr_mu_init"); gpr_mu_destroy_import = (gpr_mu_destroy_type) GetProcAddress(library, "gpr_mu_destroy"); gpr_mu_lock_import = (gpr_mu_lock_type) GetProcAddress(library, "gpr_mu_lock"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index d701d2f571..afcf573863 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -35,13 +35,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -619,33 +617,6 @@ extern gpr_avl_maybe_get_type gpr_avl_maybe_get_import; typedef int(*gpr_avl_is_empty_type)(gpr_avl avl); extern gpr_avl_is_empty_type gpr_avl_is_empty_import; #define gpr_avl_is_empty gpr_avl_is_empty_import -typedef gpr_cmdline*(*gpr_cmdline_create_type)(const char* description); -extern gpr_cmdline_create_type gpr_cmdline_create_import; -#define gpr_cmdline_create gpr_cmdline_create_import -typedef void(*gpr_cmdline_add_int_type)(gpr_cmdline* cl, const char* name, const char* help, int* value); -extern gpr_cmdline_add_int_type gpr_cmdline_add_int_import; -#define gpr_cmdline_add_int gpr_cmdline_add_int_import -typedef void(*gpr_cmdline_add_flag_type)(gpr_cmdline* cl, const char* name, const char* help, int* value); -extern gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; -#define gpr_cmdline_add_flag gpr_cmdline_add_flag_import -typedef void(*gpr_cmdline_add_string_type)(gpr_cmdline* cl, const char* name, const char* help, const char** value); -extern gpr_cmdline_add_string_type gpr_cmdline_add_string_import; -#define gpr_cmdline_add_string gpr_cmdline_add_string_import -typedef void(*gpr_cmdline_on_extra_arg_type)(gpr_cmdline* cl, const char* name, const char* help, void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); -extern gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; -#define gpr_cmdline_on_extra_arg gpr_cmdline_on_extra_arg_import -typedef void(*gpr_cmdline_set_survive_failure_type)(gpr_cmdline* cl); -extern gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; -#define gpr_cmdline_set_survive_failure gpr_cmdline_set_survive_failure_import -typedef int(*gpr_cmdline_parse_type)(gpr_cmdline* cl, int argc, char** argv); -extern gpr_cmdline_parse_type gpr_cmdline_parse_import; -#define gpr_cmdline_parse gpr_cmdline_parse_import -typedef void(*gpr_cmdline_destroy_type)(gpr_cmdline* cl); -extern gpr_cmdline_destroy_type gpr_cmdline_destroy_import; -#define gpr_cmdline_destroy gpr_cmdline_destroy_import -typedef char*(*gpr_cmdline_usage_string_type)(gpr_cmdline* cl, const char* argv0); -extern gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; -#define gpr_cmdline_usage_string gpr_cmdline_usage_string_import typedef unsigned(*gpr_cpu_num_cores_type)(void); extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import; #define gpr_cpu_num_cores gpr_cpu_num_cores_import @@ -685,21 +656,6 @@ extern gpr_strdup_type gpr_strdup_import; typedef int(*gpr_asprintf_type)(char** strp, const char* format, ...) GPR_PRINT_FORMAT_CHECK(2, 3); extern gpr_asprintf_type gpr_asprintf_import; #define gpr_asprintf gpr_asprintf_import -typedef const char*(*gpr_subprocess_binary_extension_type)(); -extern gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; -#define gpr_subprocess_binary_extension gpr_subprocess_binary_extension_import -typedef gpr_subprocess*(*gpr_subprocess_create_type)(int argc, const char** argv); -extern gpr_subprocess_create_type gpr_subprocess_create_import; -#define gpr_subprocess_create gpr_subprocess_create_import -typedef void(*gpr_subprocess_destroy_type)(gpr_subprocess* p); -extern gpr_subprocess_destroy_type gpr_subprocess_destroy_import; -#define gpr_subprocess_destroy gpr_subprocess_destroy_import -typedef int(*gpr_subprocess_join_type)(gpr_subprocess* p); -extern gpr_subprocess_join_type gpr_subprocess_join_import; -#define gpr_subprocess_join gpr_subprocess_join_import -typedef void(*gpr_subprocess_interrupt_type)(gpr_subprocess* p); -extern gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; -#define gpr_subprocess_interrupt gpr_subprocess_interrupt_import typedef void(*gpr_mu_init_type)(gpr_mu* mu); extern gpr_mu_init_type gpr_mu_init_import; #define gpr_mu_init gpr_mu_init_import diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8a7960b5ed..1979ecbb17 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,11 +25,11 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/bad_ssl/server_common.cc b/test/core/bad_ssl/server_common.cc index 08842b8350..809539aff3 100644 --- a/test/core/bad_ssl/server_common.cc +++ b/test/core/bad_ssl/server_common.cc @@ -16,11 +16,11 @@ * */ -#include #include #include #include "test/core/bad_ssl/server_common.h" +#include "test/core/util/cmdline.h" #include "test/core/util/test_config.h" /* Common server implementation details for all servers in servers/. diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc index 28e62e0e83..b6d6cb9518 100644 --- a/test/core/fling/client.cc +++ b/test/core/fling/client.cc @@ -21,11 +21,11 @@ #include #include -#include #include #include #include #include "src/core/lib/profiling/timers.h" +#include "test/core/util/cmdline.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" #include "test/core/util/test_config.h" diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index b5a5ce816e..48df6d5fb3 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -22,9 +22,10 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, char** argv) { char* me = argv[0]; diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3792e45c42..7586be234f 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -22,9 +22,10 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, const char** argv) { const char* me = argv[0]; diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index f3a8a1ccf8..097730b5d7 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -30,12 +30,12 @@ #endif #include -#include #include #include #include #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/cmdline.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index 1be1036d04..27fd9e180b 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -38,16 +38,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "cmdline_test", - srcs = ["cmdline_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:gpr_test_util", - ], -) - grpc_cc_test( name = "cpu_test", srcs = ["cpu_test.cc"], diff --git a/test/core/gpr/cmdline_test.cc b/test/core/gpr/cmdline_test.cc deleted file mode 100644 index 172efda8a0..0000000000 --- a/test/core/gpr/cmdline_test.cc +++ /dev/null @@ -1,491 +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. - * - */ - -#include - -#include - -#include -#include -#include -#include "test/core/util/test_config.h" - -#define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__) - -static void test_simple_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("-foo"), - const_cast("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_eq_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("-foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo"), - const_cast("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_eq_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_simple_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("-foo"), - const_cast("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_eq_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("-foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo"), - const_cast("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_eq_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_flag_on(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_no(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--no-foo")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_1(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=1")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_0(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=0")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_true(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=true")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_false(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {(char*)__FILE__, const_cast("--foo=false")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_many(void) { - const char* str = nullptr; - int x = 0; - int flag = 2; - gpr_cmdline* cl; - - char* args[] = {(char*)__FILE__, const_cast("--str"), - const_cast("hello"), const_cast("-x=4"), - const_cast("-no-flag")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 4); - GPR_ASSERT(0 == strcmp(str, "hello")); - GPR_ASSERT(flag == 0); - gpr_cmdline_destroy(cl); -} - -static void extra_arg_cb(void* user_data, const char* arg) { - int* count = static_cast(user_data); - GPR_ASSERT(arg != nullptr); - GPR_ASSERT(strlen(arg) == 1); - GPR_ASSERT(arg[0] == 'a' + *count); - ++*count; -} - -static void test_extra(void) { - gpr_cmdline* cl; - int count = 0; - char* args[] = {(char*)__FILE__, const_cast("a"), - const_cast("b"), const_cast("c")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - &count); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(count == 3); - gpr_cmdline_destroy(cl); -} - -static void test_extra_dashdash(void) { - gpr_cmdline* cl; - int count = 0; - char* args[] = {(char*)__FILE__, const_cast("--"), - const_cast("a"), const_cast("b"), - const_cast("c")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - &count); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(count == 3); - gpr_cmdline_destroy(cl); -} - -static void test_usage(void) { - gpr_cmdline* cl; - char* usage; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - usage = gpr_cmdline_usage_string(cl, "test"); - GPR_ASSERT(0 == strcmp(usage, - "Usage: test [--str=string] [--x=int] " - "[--flag|--no-flag] [file...]\n")); - gpr_free(usage); - - usage = gpr_cmdline_usage_string(cl, "/foo/test"); - GPR_ASSERT(0 == strcmp(usage, - "Usage: test [--str=string] [--x=int] " - "[--flag|--no-flag] [file...]\n")); - gpr_free(usage); - - gpr_cmdline_destroy(cl); -} - -static void test_help(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* help[] = {(char*)__FILE__, const_cast("-h")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(help), help)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs1(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_arg_name[] = {(char*)__FILE__, const_cast("--y")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_arg_name), bad_arg_name)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs2(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_int_value[] = {(char*)__FILE__, const_cast("--x"), - const_cast("henry")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT( - 0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_int_value), bad_int_value)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs3(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_bool_value[] = {(char*)__FILE__, const_cast("--flag=henry")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), - bad_bool_value)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs4(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_bool_value[] = {(char*)__FILE__, const_cast("--no-str")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), - bad_bool_value)); - - gpr_cmdline_destroy(cl); -} - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - test_simple_int(); - test_eq_int(); - test_2dash_int(); - test_2dash_eq_int(); - test_simple_string(); - test_eq_string(); - test_2dash_string(); - test_2dash_eq_string(); - test_flag_on(); - test_flag_no(); - test_flag_val_1(); - test_flag_val_0(); - test_flag_val_true(); - test_flag_val_false(); - test_many(); - test_extra(); - test_extra_dashdash(); - test_usage(); - test_help(); - test_badargs1(); - test_badargs2(); - test_badargs3(); - test_badargs4(); - return 0; -} diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 259e3aa463..aa9416c3dd 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -24,10 +24,11 @@ #include #include #include -#include #include + #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static int g_done = 0; diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index adf69f1b16..ed2016e643 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -24,10 +24,11 @@ #include #include #include -#include #include + #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static int g_done = 0; diff --git a/test/core/json/json_rewrite.cc b/test/core/json/json_rewrite.cc index 6891a57f9f..0319d15024 100644 --- a/test/core/json/json_rewrite.cc +++ b/test/core/json/json_rewrite.cc @@ -20,11 +20,11 @@ #include #include -#include #include #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" +#include "test/core/util/cmdline.h" typedef struct json_writer_userdata { FILE* out; diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index ca841434aa..e8b3540f46 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -24,12 +24,13 @@ #include #include #include -#include #include #include #include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" + +#include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" #include "test/core/util/test_config.h" diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index fb6d290130..bf248c92ba 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -22,9 +22,10 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, char** argv) { char* me = argv[0]; diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 60ebcece3e..4303ec70ec 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -30,11 +30,11 @@ #endif #include -#include #include #include #include #include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index fb982a10fd..dd577867ab 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -35,13 +35,13 @@ #include #include -#include #include #include #include #include #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/socket_utils_posix.h" +#include "test/core/util/cmdline.h" #include "test/core/util/histogram.h" typedef struct fd_pair { diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 7cd3ae58da..425c617fd1 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -110,6 +110,7 @@ grpc_cc_binary( deps = [ "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) @@ -121,6 +122,7 @@ grpc_cc_binary( ":oauth2_utils", "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) @@ -131,5 +133,6 @@ grpc_cc_binary( deps = [ "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index 56ae9c891c..bb8227f08f 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -24,9 +24,10 @@ #include #include -#include #include +#include "test/core/util/cmdline.h" + void create_jwt(const char* json_key_file_path, const char* service_url, const char* scope) { grpc_auth_json_key key; diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index cb28a0487c..b0fa514400 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -23,13 +23,13 @@ #include #include #include -#include #include #include #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/security/oauth2_utils.h" +#include "test/core/util/cmdline.h" static grpc_call_credentials* create_refresh_token_creds( const char* json_refresh_token_file_path) { diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index a90f997bda..828694afd1 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -31,6 +30,7 @@ #include "src/core/lib/security/credentials/composite/composite_credentials.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "test/core/util/cmdline.h" typedef struct { gpr_mu* mu; diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 5d32ce0cdb..747508f6f6 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -23,11 +23,11 @@ #include #include #include -#include #include #include #include "src/core/lib/security/credentials/jwt/jwt_verifier.h" +#include "test/core/util/cmdline.h" typedef struct { grpc_pollset* pollset; diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index f4de5d7d8a..a191987577 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -48,13 +48,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -255,15 +253,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_avl_get); printf("%lx", (unsigned long) gpr_avl_maybe_get); printf("%lx", (unsigned long) gpr_avl_is_empty); - printf("%lx", (unsigned long) gpr_cmdline_create); - printf("%lx", (unsigned long) gpr_cmdline_add_int); - printf("%lx", (unsigned long) gpr_cmdline_add_flag); - printf("%lx", (unsigned long) gpr_cmdline_add_string); - printf("%lx", (unsigned long) gpr_cmdline_on_extra_arg); - printf("%lx", (unsigned long) gpr_cmdline_set_survive_failure); - printf("%lx", (unsigned long) gpr_cmdline_parse); - printf("%lx", (unsigned long) gpr_cmdline_destroy); - printf("%lx", (unsigned long) gpr_cmdline_usage_string); printf("%lx", (unsigned long) gpr_cpu_num_cores); printf("%lx", (unsigned long) gpr_cpu_current_cpu); printf("%lx", (unsigned long) gpr_join_host_port); @@ -276,11 +265,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_set_log_function); printf("%lx", (unsigned long) gpr_strdup); printf("%lx", (unsigned long) gpr_asprintf); - printf("%lx", (unsigned long) gpr_subprocess_binary_extension); - printf("%lx", (unsigned long) gpr_subprocess_create); - printf("%lx", (unsigned long) gpr_subprocess_destroy); - printf("%lx", (unsigned long) gpr_subprocess_join); - printf("%lx", (unsigned long) gpr_subprocess_interrupt); printf("%lx", (unsigned long) gpr_mu_init); printf("%lx", (unsigned long) gpr_mu_destroy); printf("%lx", (unsigned long) gpr_mu_lock); diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 2237cfc173..886cfddf86 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -51,6 +51,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_test_util_base", srcs = [ + "cmdline.cc", "grpc_profiler.cc", "histogram.cc", "mock_endpoint.cc", @@ -61,11 +62,14 @@ grpc_cc_library( "port_server_client.cc", "reconnect_server.cc", "slice_splitter.cc", + "subprocess_posix.cc", + "subprocess_windows.cc", "test_tcp_server.cc", "tracer_util.cc", "trickle_endpoint.cc", ], hdrs = [ + "cmdline.h", "grpc_profiler.h", "histogram.h", "mock_endpoint.h", @@ -74,6 +78,7 @@ grpc_cc_library( "port.h", "port_server_client.h", "reconnect_server.h", + "subprocess.h", "slice_splitter.h", "test_tcp_server.h", "tracer_util.h", @@ -109,6 +114,16 @@ grpc_cc_library( ], ) +grpc_cc_test( + name = "cmdline_test", + srcs = ["cmdline_test.cc"], + language = "C++", + deps = [ + ":grpc_test_util", + "//:gpr", + ], +) + grpc_cc_library( name = "fuzzer_corpus_test", testonly = 1, diff --git a/test/core/util/cmdline.cc b/test/core/util/cmdline.cc new file mode 100644 index 0000000000..20bce273cd --- /dev/null +++ b/test/core/util/cmdline.cc @@ -0,0 +1,330 @@ +/* + * + * 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 "test/core/util/cmdline.h" + +#include +#include +#include + +#include +#include +#include +#include "src/core/lib/gpr/string.h" + +typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype; + +typedef struct arg { + const char* name; + const char* help; + argtype type; + void* value; + struct arg* next; +} arg; + +struct gpr_cmdline { + const char* description; + arg* args; + const char* argv0; + + const char* extra_arg_name; + const char* extra_arg_help; + void (*extra_arg)(void* user_data, const char* arg); + void* extra_arg_user_data; + + int (*state)(gpr_cmdline* cl, char* arg); + arg* cur_arg; + + int survive_failure; +}; + +static int normal_state(gpr_cmdline* cl, char* arg); + +gpr_cmdline* gpr_cmdline_create(const char* description) { + gpr_cmdline* cl = (gpr_cmdline*)gpr_zalloc(sizeof(gpr_cmdline)); + + cl->description = description; + cl->state = normal_state; + + return cl; +} + +void gpr_cmdline_set_survive_failure(gpr_cmdline* cl) { + cl->survive_failure = 1; +} + +void gpr_cmdline_destroy(gpr_cmdline* cl) { + while (cl->args) { + arg* a = cl->args; + cl->args = a->next; + gpr_free(a); + } + gpr_free(cl); +} + +static void add_arg(gpr_cmdline* cl, const char* name, const char* help, + argtype type, void* value) { + arg* a; + + for (a = cl->args; a; a = a->next) { + GPR_ASSERT(0 != strcmp(a->name, name)); + } + + a = (arg*)gpr_zalloc(sizeof(arg)); + a->name = name; + a->help = help; + a->type = type; + a->value = value; + a->next = cl->args; + cl->args = a; +} + +void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, + int* value) { + add_arg(cl, name, help, ARGTYPE_INT, value); +} + +void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, + int* value) { + add_arg(cl, name, help, ARGTYPE_BOOL, value); +} + +void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, + const char** value) { + add_arg(cl, name, help, ARGTYPE_STRING, value); +} + +void gpr_cmdline_on_extra_arg( + gpr_cmdline* cl, const char* name, const char* help, + void (*on_extra_arg)(void* user_data, const char* arg), void* user_data) { + GPR_ASSERT(!cl->extra_arg); + GPR_ASSERT(on_extra_arg); + + cl->extra_arg = on_extra_arg; + cl->extra_arg_user_data = user_data; + cl->extra_arg_name = name; + cl->extra_arg_help = help; +} + +/* recursively descend argument list, adding the last element + to s first - so that arguments are added in the order they were + added to the list by api calls */ +static void add_args_to_usage(gpr_strvec* s, arg* a) { + char* tmp; + + if (!a) return; + add_args_to_usage(s, a->next); + + switch (a->type) { + case ARGTYPE_BOOL: + gpr_asprintf(&tmp, " [--%s|--no-%s]", a->name, a->name); + gpr_strvec_add(s, tmp); + break; + case ARGTYPE_STRING: + gpr_asprintf(&tmp, " [--%s=string]", a->name); + gpr_strvec_add(s, tmp); + break; + case ARGTYPE_INT: + gpr_asprintf(&tmp, " [--%s=int]", a->name); + gpr_strvec_add(s, tmp); + break; + } +} + +char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) { + /* TODO(ctiller): make this prettier */ + gpr_strvec s; + char* tmp; + const char* name = strrchr(argv0, '/'); + + if (name) { + name++; + } else { + name = argv0; + } + + gpr_strvec_init(&s); + + gpr_asprintf(&tmp, "Usage: %s", name); + gpr_strvec_add(&s, tmp); + add_args_to_usage(&s, cl->args); + if (cl->extra_arg) { + gpr_asprintf(&tmp, " [%s...]", cl->extra_arg_name); + gpr_strvec_add(&s, tmp); + } + gpr_strvec_add(&s, gpr_strdup("\n")); + + tmp = gpr_strvec_flatten(&s, nullptr); + gpr_strvec_destroy(&s); + return tmp; +} + +static int print_usage_and_die(gpr_cmdline* cl) { + char* usage = gpr_cmdline_usage_string(cl, cl->argv0); + fprintf(stderr, "%s", usage); + gpr_free(usage); + if (!cl->survive_failure) { + exit(1); + } + return 0; +} + +static int extra_state(gpr_cmdline* cl, char* str) { + if (!cl->extra_arg) { + return print_usage_and_die(cl); + } + cl->extra_arg(cl->extra_arg_user_data, str); + return 1; +} + +static arg* find_arg(gpr_cmdline* cl, char* name) { + arg* a; + + for (a = cl->args; a; a = a->next) { + if (0 == strcmp(a->name, name)) { + break; + } + } + + if (!a) { + fprintf(stderr, "Unknown argument: %s\n", name); + return nullptr; + } + + return a; +} + +static int value_state(gpr_cmdline* cl, char* str) { + long intval; + char* end; + + GPR_ASSERT(cl->cur_arg); + + switch (cl->cur_arg->type) { + case ARGTYPE_INT: + intval = strtol(str, &end, 0); + if (*end || intval < INT_MIN || intval > INT_MAX) { + fprintf(stderr, "expected integer, got '%s' for %s\n", str, + cl->cur_arg->name); + return print_usage_and_die(cl); + } + *(int*)cl->cur_arg->value = (int)intval; + break; + case ARGTYPE_BOOL: + if (0 == strcmp(str, "1") || 0 == strcmp(str, "true")) { + *(int*)cl->cur_arg->value = 1; + } else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) { + *(int*)cl->cur_arg->value = 0; + } else { + fprintf(stderr, "expected boolean, got '%s' for %s\n", str, + cl->cur_arg->name); + return print_usage_and_die(cl); + } + break; + case ARGTYPE_STRING: + *(char**)cl->cur_arg->value = str; + break; + } + + cl->state = normal_state; + return 1; +} + +static int normal_state(gpr_cmdline* cl, char* str) { + char* eq = nullptr; + char* tmp = nullptr; + char* arg_name = nullptr; + int r = 1; + + if (0 == strcmp(str, "-help") || 0 == strcmp(str, "--help") || + 0 == strcmp(str, "-h")) { + return print_usage_and_die(cl); + } + + cl->cur_arg = nullptr; + + if (str[0] == '-') { + if (str[1] == '-') { + if (str[2] == 0) { + /* handle '--' to move to just extra args */ + cl->state = extra_state; + return 1; + } + str += 2; + } else { + str += 1; + } + /* first byte of str is now past the leading '-' or '--' */ + if (str[0] == 'n' && str[1] == 'o' && str[2] == '-') { + /* str is of the form '--no-foo' - it's a flag disable */ + str += 3; + cl->cur_arg = find_arg(cl, str); + if (cl->cur_arg == nullptr) { + return print_usage_and_die(cl); + } + if (cl->cur_arg->type != ARGTYPE_BOOL) { + fprintf(stderr, "%s is not a flag argument\n", str); + return print_usage_and_die(cl); + } + *(int*)cl->cur_arg->value = 0; + return 1; /* early out */ + } + eq = strchr(str, '='); + if (eq != nullptr) { + /* copy the string into a temp buffer and extract the name */ + tmp = arg_name = (char*)gpr_malloc((size_t)(eq - str + 1)); + memcpy(arg_name, str, (size_t)(eq - str)); + arg_name[eq - str] = 0; + } else { + arg_name = str; + } + cl->cur_arg = find_arg(cl, arg_name); + if (cl->cur_arg == nullptr) { + return print_usage_and_die(cl); + } + if (eq != nullptr) { + /* str was of the type --foo=value, parse the value */ + r = value_state(cl, eq + 1); + } else if (cl->cur_arg->type != ARGTYPE_BOOL) { + /* flag types don't have a '--foo value' variant, other types do */ + cl->state = value_state; + } else { + /* flag parameter: just set the value */ + *(int*)cl->cur_arg->value = 1; + } + } else { + r = extra_state(cl, str); + } + + gpr_free(tmp); + return r; +} + +int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv) { + int i; + + GPR_ASSERT(argc >= 1); + cl->argv0 = argv[0]; + + for (i = 1; i < argc; i++) { + if (!cl->state(cl, argv[i])) { + return 0; + } + } + return 1; +} diff --git a/test/core/util/cmdline.h b/test/core/util/cmdline.h new file mode 100644 index 0000000000..54f45167fa --- /dev/null +++ b/test/core/util/cmdline.h @@ -0,0 +1,88 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_TEST_CORE_UTIL_CMDLINE_H +#define GRPC_TEST_CORE_UTIL_CMDLINE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Simple command line parser. + + Supports flags that can be specified as -foo, --foo, --no-foo, -no-foo, etc + And integers, strings that can be specified as -foo=4, -foo blah, etc + + No support for short command line options (but we may get that in the + future.) + + Usage (for a program with a single flag argument 'foo'): + + int main(int argc, char **argv) { + gpr_cmdline *cl; + int verbose = 0; + + cl = gpr_cmdline_create("My cool tool"); + gpr_cmdline_add_int(cl, "verbose", "Produce verbose output?", &verbose); + gpr_cmdline_parse(cl, argc, argv); + gpr_cmdline_destroy(cl); + + if (verbose) { + gpr_log(GPR_INFO, "Goodbye cruel world!"); + } + + return 0; + } */ + +typedef struct gpr_cmdline gpr_cmdline; + +/** Construct a command line parser: takes a short description of the tool + doing the parsing */ +gpr_cmdline* gpr_cmdline_create(const char* description); +/** Add an integer parameter, with a name (used on the command line) and some + helpful text (used in the command usage) */ +void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, + int* value); +/** The same, for a boolean flag */ +void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, + int* value); +/** And for a string */ +void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, + const char** value); +/** Set a callback for non-named arguments */ +void gpr_cmdline_on_extra_arg( + gpr_cmdline* cl, const char* name, const char* help, + void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); +/** Enable surviving failure: default behavior is to exit the process */ +void gpr_cmdline_set_survive_failure(gpr_cmdline* cl); +/** Parse the command line; returns 1 on success, on failure either dies + (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been + called */ +int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv); +/** Destroy the parser */ +void gpr_cmdline_destroy(gpr_cmdline* cl); +/** Get a string describing usage */ +char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_TEST_CORE_UTIL_CMDLINE_H */ diff --git a/test/core/util/cmdline_test.cc b/test/core/util/cmdline_test.cc new file mode 100644 index 0000000000..ed4412aa9f --- /dev/null +++ b/test/core/util/cmdline_test.cc @@ -0,0 +1,491 @@ +/* + * + * 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 + +#include +#include +#include + +#include "test/core/util/cmdline.h" +#include "test/core/util/test_config.h" + +#define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__) + +static void test_simple_int(void) { + int x = 1; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("-foo"), + const_cast("3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_int(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 1); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 3); + gpr_cmdline_destroy(cl); +} + +static void test_eq_int(void) { + int x = 1; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("-foo=3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_int(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 1); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 3); + gpr_cmdline_destroy(cl); +} + +static void test_2dash_int(void) { + int x = 1; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo"), + const_cast("3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_int(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 1); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 3); + gpr_cmdline_destroy(cl); +} + +static void test_2dash_eq_int(void) { + int x = 1; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_int(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 1); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 3); + gpr_cmdline_destroy(cl); +} + +static void test_simple_string(void) { + const char* x = nullptr; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("-foo"), + const_cast("3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "foo", nullptr, &x); + GPR_ASSERT(x == nullptr); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(0 == strcmp(x, "3")); + gpr_cmdline_destroy(cl); +} + +static void test_eq_string(void) { + const char* x = nullptr; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("-foo=3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "foo", nullptr, &x); + GPR_ASSERT(x == nullptr); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(0 == strcmp(x, "3")); + gpr_cmdline_destroy(cl); +} + +static void test_2dash_string(void) { + const char* x = nullptr; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo"), + const_cast("3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "foo", nullptr, &x); + GPR_ASSERT(x == nullptr); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(0 == strcmp(x, "3")); + gpr_cmdline_destroy(cl); +} + +static void test_2dash_eq_string(void) { + const char* x = nullptr; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=3")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "foo", nullptr, &x); + GPR_ASSERT(x == nullptr); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(0 == strcmp(x, "3")); + gpr_cmdline_destroy(cl); +} + +static void test_flag_on(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 1); + gpr_cmdline_destroy(cl); +} + +static void test_flag_no(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--no-foo")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 0); + gpr_cmdline_destroy(cl); +} + +static void test_flag_val_1(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=1")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 1); + gpr_cmdline_destroy(cl); +} + +static void test_flag_val_0(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=0")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 0); + gpr_cmdline_destroy(cl); +} + +static void test_flag_val_true(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=true")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 1); + gpr_cmdline_destroy(cl); +} + +static void test_flag_val_false(void) { + int x = 2; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast("--foo=false")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_flag(cl, "foo", nullptr, &x); + GPR_ASSERT(x == 2); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 0); + gpr_cmdline_destroy(cl); +} + +static void test_many(void) { + const char* str = nullptr; + int x = 0; + int flag = 2; + gpr_cmdline* cl; + + char* args[] = {(char*)__FILE__, const_cast("--str"), + const_cast("hello"), const_cast("-x=4"), + const_cast("-no-flag")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(x == 4); + GPR_ASSERT(0 == strcmp(str, "hello")); + GPR_ASSERT(flag == 0); + gpr_cmdline_destroy(cl); +} + +static void extra_arg_cb(void* user_data, const char* arg) { + int* count = static_cast(user_data); + GPR_ASSERT(arg != nullptr); + GPR_ASSERT(strlen(arg) == 1); + GPR_ASSERT(arg[0] == 'a' + *count); + ++*count; +} + +static void test_extra(void) { + gpr_cmdline* cl; + int count = 0; + char* args[] = {(char*)__FILE__, const_cast("a"), + const_cast("b"), const_cast("c")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + &count); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(count == 3); + gpr_cmdline_destroy(cl); +} + +static void test_extra_dashdash(void) { + gpr_cmdline* cl; + int count = 0; + char* args[] = {(char*)__FILE__, const_cast("--"), + const_cast("a"), const_cast("b"), + const_cast("c")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + &count); + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); + GPR_ASSERT(count == 3); + gpr_cmdline_destroy(cl); +} + +static void test_usage(void) { + gpr_cmdline* cl; + char* usage; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + usage = gpr_cmdline_usage_string(cl, "test"); + GPR_ASSERT(0 == strcmp(usage, + "Usage: test [--str=string] [--x=int] " + "[--flag|--no-flag] [file...]\n")); + gpr_free(usage); + + usage = gpr_cmdline_usage_string(cl, "/foo/test"); + GPR_ASSERT(0 == strcmp(usage, + "Usage: test [--str=string] [--x=int] " + "[--flag|--no-flag] [file...]\n")); + gpr_free(usage); + + gpr_cmdline_destroy(cl); +} + +static void test_help(void) { + gpr_cmdline* cl; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + char* help[] = {(char*)__FILE__, const_cast("-h")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_set_survive_failure(cl); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(help), help)); + + gpr_cmdline_destroy(cl); +} + +static void test_badargs1(void) { + gpr_cmdline* cl; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + char* bad_arg_name[] = {(char*)__FILE__, const_cast("--y")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_set_survive_failure(cl); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + GPR_ASSERT(0 == + gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_arg_name), bad_arg_name)); + + gpr_cmdline_destroy(cl); +} + +static void test_badargs2(void) { + gpr_cmdline* cl; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + char* bad_int_value[] = {(char*)__FILE__, const_cast("--x"), + const_cast("henry")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_set_survive_failure(cl); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + GPR_ASSERT( + 0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_int_value), bad_int_value)); + + gpr_cmdline_destroy(cl); +} + +static void test_badargs3(void) { + gpr_cmdline* cl; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + char* bad_bool_value[] = {(char*)__FILE__, const_cast("--flag=henry")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_set_survive_failure(cl); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), + bad_bool_value)); + + gpr_cmdline_destroy(cl); +} + +static void test_badargs4(void) { + gpr_cmdline* cl; + + const char* str = nullptr; + int x = 0; + int flag = 2; + + char* bad_bool_value[] = {(char*)__FILE__, const_cast("--no-str")}; + + LOG_TEST(); + + cl = gpr_cmdline_create(nullptr); + gpr_cmdline_set_survive_failure(cl); + gpr_cmdline_add_string(cl, "str", nullptr, &str); + gpr_cmdline_add_int(cl, "x", nullptr, &x); + gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); + gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, + nullptr); + + GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), + bad_bool_value)); + + gpr_cmdline_destroy(cl); +} + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + test_simple_int(); + test_eq_int(); + test_2dash_int(); + test_2dash_eq_int(); + test_simple_string(); + test_eq_string(); + test_2dash_string(); + test_2dash_eq_string(); + test_flag_on(); + test_flag_no(); + test_flag_val_1(); + test_flag_val_0(); + test_flag_val_true(); + test_flag_val_false(); + test_many(); + test_extra(); + test_extra_dashdash(); + test_usage(); + test_help(); + test_badargs1(); + test_badargs2(); + test_badargs3(); + test_badargs4(); + return 0; +} diff --git a/test/core/util/subprocess.h b/test/core/util/subprocess.h new file mode 100644 index 0000000000..7419de27bb --- /dev/null +++ b/test/core/util/subprocess.h @@ -0,0 +1,44 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_TEST_CORE_UTIL_SUBPROCESS_H +#define GRPC_TEST_CORE_UTIL_SUBPROCESS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct gpr_subprocess gpr_subprocess; + +/** .exe on windows, empty on unices */ +const char* gpr_subprocess_binary_extension(); + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); +/** if subprocess has not been joined, kill it */ +void gpr_subprocess_destroy(gpr_subprocess* p); +/** returns exit status; can be called at most once */ +int gpr_subprocess_join(gpr_subprocess* p); +void gpr_subprocess_interrupt(gpr_subprocess* p); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* GRPC_TEST_CORE_UTIL_SUBPROCESS_H */ diff --git a/test/core/util/subprocess_posix.cc b/test/core/util/subprocess_posix.cc new file mode 100644 index 0000000000..0f6c99731f --- /dev/null +++ b/test/core/util/subprocess_posix.cc @@ -0,0 +1,99 @@ +/* + * + * 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 + +#ifdef GPR_POSIX_SUBPROCESS + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "test/core/util/subprocess.h" + +struct gpr_subprocess { + int pid; + bool joined; +}; + +const char* gpr_subprocess_binary_extension() { return ""; } + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { + gpr_subprocess* r; + int pid; + char** exec_args; + + pid = fork(); + if (pid == -1) { + return nullptr; + } else if (pid == 0) { + exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*)); + memcpy(exec_args, argv, (size_t)argc * sizeof(char*)); + exec_args[argc] = nullptr; + execv(exec_args[0], exec_args); + /* if we reach here, an error has occurred */ + gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno)); + _exit(1); + return nullptr; + } else { + r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess)); + r->pid = pid; + return r; + } +} + +void gpr_subprocess_destroy(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGKILL); + gpr_subprocess_join(p); + } + gpr_free(p); +} + +int gpr_subprocess_join(gpr_subprocess* p) { + int status; +retry: + if (waitpid(p->pid, &status, 0) == -1) { + if (errno == EINTR) { + goto retry; + } + gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid, + strerror(errno)); + return -1; + } + p->joined = true; + return status; +} + +void gpr_subprocess_interrupt(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGINT); + } +} + +#endif /* GPR_POSIX_SUBPROCESS */ diff --git a/test/core/util/subprocess_windows.cc b/test/core/util/subprocess_windows.cc new file mode 100644 index 0000000000..d3295244ea --- /dev/null +++ b/test/core/util/subprocess_windows.cc @@ -0,0 +1,126 @@ +/* + * + * 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 + +#ifdef GPR_WINDOWS_SUBPROCESS + +#include +#include +#include + +#include +#include +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/string_windows.h" +#include "test/core/util/subprocess.h" + +struct gpr_subprocess { + PROCESS_INFORMATION pi; + int joined; + int interrupted; +}; + +const char* gpr_subprocess_binary_extension() { return ".exe"; } + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { + gpr_subprocess* r; + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + char* args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); + TCHAR* args_tchar; + + args_tchar = gpr_char_to_tchar(args); + gpr_free(args); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + memset(&pi, 0, sizeof(pi)); + + if (!CreateProcess(NULL, args_tchar, NULL, NULL, FALSE, + CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { + gpr_free(args_tchar); + return NULL; + } + gpr_free(args_tchar); + + r = (gpr_subprocess*)gpr_malloc(sizeof(gpr_subprocess)); + memset(r, 0, sizeof(*r)); + r->pi = pi; + return r; +} + +void gpr_subprocess_destroy(gpr_subprocess* p) { + if (p) { + if (!p->joined) { + gpr_subprocess_interrupt(p); + gpr_subprocess_join(p); + } + if (p->pi.hProcess) { + CloseHandle(p->pi.hProcess); + } + if (p->pi.hThread) { + CloseHandle(p->pi.hThread); + } + gpr_free(p); + } +} + +int gpr_subprocess_join(gpr_subprocess* p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + if (WaitForSingleObject(p->pi.hProcess, INFINITE) == WAIT_OBJECT_0) { + p->joined = 1; + goto getExitCode; + } + return -1; // failed to join + } else { + goto getExitCode; + } + } else { + return -1; // failed to get exit code + } + +getExitCode: + if (p->interrupted) { + return 0; + } + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + return (int)dwExitCode; + } else { + return -1; // failed to get exit code + } +} + +void gpr_subprocess_interrupt(gpr_subprocess* p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + gpr_log(GPR_INFO, "sending ctrl-break"); + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, p->pi.dwProcessId); + p->joined = 1; + p->interrupted = 1; + } + } + return; +} + +#endif /* GPR_WINDOWS_SUBPROCESS */ diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 19e15b1adf..8818999a50 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -74,6 +74,7 @@ grpc_cc_library( deps = [ "//:grpc++", "//test/core/end2end:ssl_test_data", + "//test/core/util:grpc_test_util", ], external_deps = [ "protobuf", @@ -86,6 +87,7 @@ grpc_cc_library( hdrs = GRPCXX_TESTUTIL_HDRS, deps = [ "//:grpc++_unsecure", + "//test/core/util:grpc_test_util", ], external_deps = [ "protobuf", diff --git a/test/cpp/util/subprocess.cc b/test/cpp/util/subprocess.cc index a54d0c087a..ddaad89805 100644 --- a/test/cpp/util/subprocess.cc +++ b/test/cpp/util/subprocess.cc @@ -20,7 +20,7 @@ #include -#include +#include "test/core/util/subprocess.h" namespace grpc { diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6873256dcd..317dd0e1eb 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -911,14 +911,12 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ -include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ -include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 2c6505ddad..3645d5d752 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -912,14 +912,12 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ -include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ -include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index e2ccc78f56..da862ecb68 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -851,14 +851,12 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ -include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ -include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 00057c2897..4c9841feab 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -851,14 +851,12 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ -include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ -include/grpc/support/subprocess.h \ include/grpc/support/sync.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ @@ -1074,7 +1072,6 @@ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/atm.cc \ src/core/lib/gpr/avl.cc \ -src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ src/core/lib/gpr/cpu_posix.cc \ @@ -1102,8 +1099,6 @@ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ src/core/lib/gpr/string_windows.h \ -src/core/lib/gpr/subprocess_posix.cc \ -src/core/lib/gpr/subprocess_windows.cc \ src/core/lib/gpr/sync.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f61288b70d..bdbcb89b3c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -264,6 +264,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "cmdline_test", + "src": [ + "test/core/util/cmdline_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -602,21 +618,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_cmdline_test", - "src": [ - "test/core/gpr/cmdline_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -951,7 +952,9 @@ { "deps": [ "gpr", - "grpc" + "gpr_test_util", + "grpc", + "grpc_test_util" ], "headers": [], "is_filegroup": false, @@ -1051,7 +1054,9 @@ { "deps": [ "gpr", - "grpc" + "gpr_test_util", + "grpc", + "grpc_test_util" ], "headers": [], "is_filegroup": false, @@ -1100,7 +1105,9 @@ { "deps": [ "gpr", - "grpc" + "gpr_test_util", + "grpc", + "grpc_test_util" ], "headers": [], "is_filegroup": false, @@ -1393,7 +1400,9 @@ { "deps": [ "gpr", - "grpc" + "gpr_test_util", + "grpc", + "grpc_test_util" ], "headers": [], "is_filegroup": false, @@ -7850,7 +7859,6 @@ "src/core/lib/gpr/arena.cc", "src/core/lib/gpr/atm.cc", "src/core/lib/gpr/avl.cc", - "src/core/lib/gpr/cmdline.cc", "src/core/lib/gpr/cpu_iphone.cc", "src/core/lib/gpr/cpu_linux.cc", "src/core/lib/gpr/cpu_posix.cc", @@ -7871,8 +7879,6 @@ "src/core/lib/gpr/string_posix.cc", "src/core/lib/gpr/string_util_windows.cc", "src/core/lib/gpr/string_windows.cc", - "src/core/lib/gpr/subprocess_posix.cc", - "src/core/lib/gpr/subprocess_windows.cc", "src/core/lib/gpr/sync.cc", "src/core/lib/gpr/sync_posix.cc", "src/core/lib/gpr/sync_windows.cc", @@ -7905,14 +7911,12 @@ "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", "include/grpc/support/avl.h", - "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", - "include/grpc/support/subprocess.h", "include/grpc/support/sync.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", @@ -7954,14 +7958,12 @@ "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", "include/grpc/support/avl.h", - "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", - "include/grpc/support/subprocess.h", "include/grpc/support/sync.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", @@ -9026,6 +9028,7 @@ "test/core/end2end/fixtures/http_proxy_fixture.h", "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.h", + "test/core/util/cmdline.h", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.h", "test/core/util/histogram.h", @@ -9036,6 +9039,7 @@ "test/core/util/port.h", "test/core/util/port_server_client.h", "test/core/util/slice_splitter.h", + "test/core/util/subprocess.h", "test/core/util/tracer_util.h", "test/core/util/trickle_endpoint.h" ], @@ -9053,6 +9057,8 @@ "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.cc", "test/core/iomgr/endpoint_tests.h", + "test/core/util/cmdline.cc", + "test/core/util/cmdline.h", "test/core/util/debugger_macros.cc", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.cc", @@ -9074,6 +9080,9 @@ "test/core/util/port_server_client.h", "test/core/util/slice_splitter.cc", "test/core/util/slice_splitter.h", + "test/core/util/subprocess.h", + "test/core/util/subprocess_posix.cc", + "test/core/util/subprocess_windows.cc", "test/core/util/tracer_util.cc", "test/core/util/tracer_util.h", "test/core/util/trickle_endpoint.cc", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 866e2c3280..8fd124014c 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -315,6 +315,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "cmdline_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, @@ -743,30 +767,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "gpr_cmdline_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, -- cgit v1.2.3 From b6cf123717b8f6e405f62dd12cb6c43664e0680a Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 25 Jan 2018 21:02:26 -0800 Subject: Privatize thread-local storage headers --- BUILD | 8 +-- CMakeLists.txt | 16 ----- Makefile | 16 ----- build.yaml | 8 +-- gRPC-C++.podspec | 8 +++ gRPC-Core.podspec | 12 ++-- grpc.gemspec | 8 +-- include/grpc/module.modulemap | 4 -- include/grpc/support/tls.h | 68 ---------------------- include/grpc/support/tls_gcc.h | 50 ---------------- include/grpc/support/tls_msvc.h | 50 ---------------- include/grpc/support/tls_pthread.h | 54 ----------------- package.xml | 8 +-- .../ext/filters/client_channel/subchannel_index.cc | 2 +- src/core/lib/gpr/tls.h | 68 ++++++++++++++++++++++ src/core/lib/gpr/tls_gcc.h | 50 ++++++++++++++++ src/core/lib/gpr/tls_msvc.h | 50 ++++++++++++++++ src/core/lib/gpr/tls_pthread.cc | 2 +- src/core/lib/gpr/tls_pthread.h | 54 +++++++++++++++++ src/core/lib/iomgr/ev_epoll1_linux.cc | 2 +- src/core/lib/iomgr/ev_epollex_linux.cc | 2 +- src/core/lib/iomgr/ev_epollsig_linux.cc | 2 +- src/core/lib/iomgr/ev_poll_posix.cc | 2 +- src/core/lib/iomgr/exec_ctx.h | 2 +- src/core/lib/iomgr/executor.cc | 2 +- src/core/lib/iomgr/timer_generic.cc | 3 +- src/core/lib/surface/completion_queue.cc | 2 +- test/core/gpr/tls_test.cc | 3 +- test/core/surface/public_headers_must_be_c89.c | 1 - test/cpp/end2end/async_end2end_test.cc | 2 +- tools/doxygen/Doxyfile.c++ | 4 -- tools/doxygen/Doxyfile.c++.internal | 8 +-- tools/doxygen/Doxyfile.core | 4 -- tools/doxygen/Doxyfile.core.internal | 8 +-- tools/run_tests/generated/sources_and_headers.json | 16 ++--- 35 files changed, 284 insertions(+), 315 deletions(-) delete mode 100644 include/grpc/support/tls.h delete mode 100644 include/grpc/support/tls_gcc.h delete mode 100644 include/grpc/support/tls_msvc.h delete mode 100644 include/grpc/support/tls_pthread.h create mode 100644 src/core/lib/gpr/tls.h create mode 100644 src/core/lib/gpr/tls_gcc.h create mode 100644 src/core/lib/gpr/tls_msvc.h create mode 100644 src/core/lib/gpr/tls_pthread.h (limited to 'BUILD') diff --git a/BUILD b/BUILD index 0a8be79e8a..45889656fd 100644 --- a/BUILD +++ b/BUILD @@ -82,10 +82,6 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/sync_windows.h", "include/grpc/support/thd.h", "include/grpc/support/time.h", - "include/grpc/support/tls.h", - "include/grpc/support/tls_gcc.h", - "include/grpc/support/tls_msvc.h", - "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", ] @@ -509,6 +505,10 @@ grpc_cc_library( "src/core/lib/gpr/string_windows.h", "src/core/lib/gpr/thd_internal.h", "src/core/lib/gpr/time_precise.h", + "src/core/lib/gpr/tls.h", + "src/core/lib/gpr/tls_gcc.h", + "src/core/lib/gpr/tls_msvc.h", + "src/core/lib/gpr/tls_pthread.h", "src/core/lib/gpr/tmpfile.h", ], language = "c++", diff --git a/CMakeLists.txt b/CMakeLists.txt index c557e9469a..4341c6a7bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -719,10 +719,6 @@ foreach(_hdr include/grpc/support/sync_windows.h include/grpc/support/thd.h include/grpc/support/time.h - include/grpc/support/tls.h - include/grpc/support/tls_gcc.h - include/grpc/support/tls_msvc.h - include/grpc/support/tls_pthread.h include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h @@ -2513,10 +2509,6 @@ foreach(_hdr include/grpc/support/sync_windows.h include/grpc/support/thd.h include/grpc/support/time.h - include/grpc/support/tls.h - include/grpc/support/tls_gcc.h - include/grpc/support/tls_msvc.h - include/grpc/support/tls_pthread.h include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h @@ -2997,10 +2989,6 @@ foreach(_hdr include/grpc/support/sync_windows.h include/grpc/support/thd.h include/grpc/support/time.h - include/grpc/support/tls.h - include/grpc/support/tls_gcc.h - include/grpc/support/tls_msvc.h - include/grpc/support/tls_pthread.h include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h @@ -3727,10 +3715,6 @@ foreach(_hdr include/grpc/support/sync_windows.h include/grpc/support/thd.h include/grpc/support/time.h - include/grpc/support/tls.h - include/grpc/support/tls_gcc.h - include/grpc/support/tls_msvc.h - include/grpc/support/tls_pthread.h include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h diff --git a/Makefile b/Makefile index 39a94d8c55..80bcfdd748 100644 --- a/Makefile +++ b/Makefile @@ -2912,10 +2912,6 @@ PUBLIC_HEADERS_C += \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ - include/grpc/support/tls.h \ - include/grpc/support/tls_gcc.h \ - include/grpc/support/tls_msvc.h \ - include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ @@ -4644,10 +4640,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ - include/grpc/support/tls.h \ - include/grpc/support/tls_gcc.h \ - include/grpc/support/tls_msvc.h \ - include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ @@ -5133,10 +5125,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ - include/grpc/support/tls.h \ - include/grpc/support/tls_gcc.h \ - include/grpc/support/tls_msvc.h \ - include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ @@ -5852,10 +5840,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ - include/grpc/support/tls.h \ - include/grpc/support/tls_gcc.h \ - include/grpc/support/tls_msvc.h \ - include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ diff --git a/build.yaml b/build.yaml index d4d5af1371..174efe8f3c 100644 --- a/build.yaml +++ b/build.yaml @@ -95,10 +95,6 @@ filegroups: - include/grpc/support/sync_windows.h - include/grpc/support/thd.h - include/grpc/support/time.h - - include/grpc/support/tls.h - - include/grpc/support/tls_gcc.h - - include/grpc/support/tls_msvc.h - - include/grpc/support/tls_pthread.h - include/grpc/support/useful.h headers: - src/core/lib/gpr/arena.h @@ -111,6 +107,10 @@ filegroups: - src/core/lib/gpr/string_windows.h - src/core/lib/gpr/thd_internal.h - src/core/lib/gpr/time_precise.h + - src/core/lib/gpr/tls.h + - src/core/lib/gpr/tls_gcc.h + - src/core/lib/gpr/tls_msvc.h + - src/core/lib/gpr/tls_pthread.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gprpp/abstract.h - src/core/lib/gprpp/atomic.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 55f33d9aef..2b23c28cf8 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -212,6 +212,10 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_windows.h', 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', + 'src/core/lib/gpr/tls.h', + 'src/core/lib/gpr/tls_gcc.h', + 'src/core/lib/gpr/tls_msvc.h', + 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', @@ -458,6 +462,10 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_windows.h', 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', + 'src/core/lib/gpr/tls.h', + 'src/core/lib/gpr/tls_gcc.h', + 'src/core/lib/gpr/tls_msvc.h', + 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7ee7bb52d2..fe074677b0 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -130,10 +130,6 @@ Pod::Spec.new do |s| 'include/grpc/support/sync_windows.h', 'include/grpc/support/thd.h', 'include/grpc/support/time.h', - 'include/grpc/support/tls.h', - 'include/grpc/support/tls_gcc.h', - 'include/grpc/support/tls_msvc.h', - 'include/grpc/support/tls_pthread.h', 'include/grpc/support/useful.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', @@ -203,6 +199,10 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_windows.h', 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', + 'src/core/lib/gpr/tls.h', + 'src/core/lib/gpr/tls_gcc.h', + 'src/core/lib/gpr/tls_msvc.h', + 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', @@ -732,6 +732,10 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_windows.h', 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', + 'src/core/lib/gpr/tls.h', + 'src/core/lib/gpr/tls_gcc.h', + 'src/core/lib/gpr/tls_msvc.h', + 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', diff --git a/grpc.gemspec b/grpc.gemspec index 41e56d0bf1..5233d61806 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -65,10 +65,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/sync_windows.h ) s.files += %w( include/grpc/support/thd.h ) s.files += %w( include/grpc/support/time.h ) - s.files += %w( include/grpc/support/tls.h ) - s.files += %w( include/grpc/support/tls_gcc.h ) - s.files += %w( include/grpc/support/tls_msvc.h ) - s.files += %w( include/grpc/support/tls_pthread.h ) s.files += %w( include/grpc/support/useful.h ) s.files += %w( include/grpc/impl/codegen/atm.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) @@ -93,6 +89,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/string_windows.h ) s.files += %w( src/core/lib/gpr/thd_internal.h ) s.files += %w( src/core/lib/gpr/time_precise.h ) + s.files += %w( src/core/lib/gpr/tls.h ) + s.files += %w( src/core/lib/gpr/tls_gcc.h ) + s.files += %w( src/core/lib/gpr/tls_msvc.h ) + s.files += %w( src/core/lib/gpr/tls_pthread.h ) s.files += %w( src/core/lib/gpr/tmpfile.h ) s.files += %w( src/core/lib/gprpp/abstract.h ) s.files += %w( src/core/lib/gprpp/atomic.h ) diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index d23072f556..cff98312c0 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -17,7 +17,6 @@ framework module grpc { header "support/sync_generic.h" header "support/thd.h" header "support/time.h" - header "support/tls.h" header "support/useful.h" header "impl/codegen/atm.h" header "impl/codegen/fork.h" @@ -63,9 +62,6 @@ framework module grpc { textual header "support/sync_custom.h" textual header "support/sync_posix.h" textual header "support/sync_windows.h" - textual header "support/tls_gcc.h" - textual header "support/tls_msvc.h" - textual header "support/tls_pthread.h" textual header "impl/codegen/atm_gcc_atomic.h" textual header "impl/codegen/atm_gcc_sync.h" textual header "impl/codegen/atm_windows.h" diff --git a/include/grpc/support/tls.h b/include/grpc/support/tls.h deleted file mode 100644 index 4c9e79b6cf..0000000000 --- a/include/grpc/support/tls.h +++ /dev/null @@ -1,68 +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. - * - */ - -#ifndef GRPC_SUPPORT_TLS_H -#define GRPC_SUPPORT_TLS_H - -#include - -/** Thread local storage. - - A minimal wrapper that should be implementable across many compilers, - and implementable efficiently across most modern compilers. - - Thread locals have type intptr_t. - - Declaring a thread local variable 'foo': - GPR_TLS_DECL(foo); - Thread locals always have static scope. - - Declaring a thread local class variable 'foo': - GPR_TLS_CLASS_DECL(foo); - - Defining the thread local class variable: - GPR_TLS_CLASS_DEF(foo); - - Initializing a thread local (must be done at library initialization - time): - gpr_tls_init(&foo); - - Destroying a thread local: - gpr_tls_destroy(&foo); - - Setting a thread local (returns new_value): - gpr_tls_set(&foo, new_value); - - Accessing a thread local: - current_value = gpr_tls_get(&foo); - - ALL functions here may be implemented as macros. */ - -#ifdef GPR_GCC_TLS -#include -#endif - -#ifdef GPR_MSVC_TLS -#include -#endif - -#ifdef GPR_PTHREAD_TLS -#include -#endif - -#endif /* GRPC_SUPPORT_TLS_H */ diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h deleted file mode 100644 index b44f0f1c8c..0000000000 --- a/include/grpc/support/tls_gcc.h +++ /dev/null @@ -1,50 +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. - * - */ - -#ifndef GRPC_SUPPORT_TLS_GCC_H -#define GRPC_SUPPORT_TLS_GCC_H - -#include - -#include - -/** Thread local storage based on gcc compiler primitives. - #include tls.h to use this - and see that file for documentation */ - -struct gpr_gcc_thread_local { - intptr_t value; -}; - -#define GPR_TLS_DECL(name) \ - static __thread struct gpr_gcc_thread_local name = {0} - -#define GPR_TLS_CLASS_DECL(name) \ - static __thread struct gpr_gcc_thread_local name - -#define GPR_TLS_CLASS_DEF(name) __thread struct gpr_gcc_thread_local name = {0} - -#define gpr_tls_init(tls) \ - do { \ - } while (0) -#define gpr_tls_destroy(tls) \ - do { \ - } while (0) -#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value)) -#define gpr_tls_get(tls) ((tls)->value) - -#endif /* GRPC_SUPPORT_TLS_GCC_H */ diff --git a/include/grpc/support/tls_msvc.h b/include/grpc/support/tls_msvc.h deleted file mode 100644 index 68a411f5d4..0000000000 --- a/include/grpc/support/tls_msvc.h +++ /dev/null @@ -1,50 +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. - * - */ - -#ifndef GRPC_SUPPORT_TLS_MSVC_H -#define GRPC_SUPPORT_TLS_MSVC_H - -/** Thread local storage based on ms visual c compiler primitives. - #include tls.h to use this - and see that file for documentation */ - -struct gpr_msvc_thread_local { - intptr_t value; -}; - -/** Use GPR_TLS_DECL to declare tls static variables outside a class */ -#define GPR_TLS_DECL(name) \ - static __declspec(thread) struct gpr_msvc_thread_local name = {0} - -/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class. - * GPR_TLS_CLASS_DEF needs to be called to define this member. */ -#define GPR_TLS_CLASS_DECL(name) \ - static __declspec(thread) struct gpr_msvc_thread_local name - -#define GPR_TLS_CLASS_DEF(name) \ - __declspec(thread) struct gpr_msvc_thread_local name = {0} - -#define gpr_tls_init(tls) \ - do { \ - } while (0) -#define gpr_tls_destroy(tls) \ - do { \ - } while (0) -#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value)) -#define gpr_tls_get(tls) ((tls)->value) - -#endif /* GRPC_SUPPORT_TLS_MSVC_H */ diff --git a/include/grpc/support/tls_pthread.h b/include/grpc/support/tls_pthread.h deleted file mode 100644 index 249c8b16f8..0000000000 --- a/include/grpc/support/tls_pthread.h +++ /dev/null @@ -1,54 +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. - * - */ - -#ifndef GRPC_SUPPORT_TLS_PTHREAD_H -#define GRPC_SUPPORT_TLS_PTHREAD_H - -#include /* for GPR_ASSERT */ -#include - -/** Thread local storage based on pthread library calls. - #include tls.h to use this - and see that file for documentation */ - -struct gpr_pthread_thread_local { - pthread_key_t key; -}; - -/** Use GPR_TLS_DECL to declare tls static variables outside a class */ -#define GPR_TLS_DECL(name) static struct gpr_pthread_thread_local name = {0} - -/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class. - * GPR_TLS_CLASS_DEF needs to be called to define this member. */ -#define GPR_TLS_CLASS_DECL(name) static struct gpr_pthread_thread_local name - -/** Use GPR_TLS_CLASS_DEF to declare tls static variable members of a class. - * GPR_TLS_CLASS_DEF needs to be called to define this member. */ -#define GPR_TLS_CLASS_DEF(name) struct gpr_pthread_thread_local name = {0} - -#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL)) -#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key) -#define gpr_tls_get(tls) ((intptr_t)pthread_getspecific((tls)->key)) -#ifdef __cplusplus -extern "C" { -#endif -intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value); -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_TLS_PTHREAD_H */ diff --git a/package.xml b/package.xml index 3f529a2096..f8b45015d3 100644 --- a/package.xml +++ b/package.xml @@ -72,10 +72,6 @@ - - - - @@ -100,6 +96,10 @@ + + + + diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc index 052b047f43..6ba0d2f745 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.cc +++ b/src/core/ext/filters/client_channel/subchannel_index.cc @@ -24,9 +24,9 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/tls.h" // a map of subchannel_key --> subchannel, used for detecting connections // to the same destination in order to share them diff --git a/src/core/lib/gpr/tls.h b/src/core/lib/gpr/tls.h new file mode 100644 index 0000000000..aee8f4d941 --- /dev/null +++ b/src/core/lib/gpr/tls.h @@ -0,0 +1,68 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_TLS_H +#define GRPC_CORE_LIB_GPR_TLS_H + +#include + +/** Thread local storage. + + A minimal wrapper that should be implementable across many compilers, + and implementable efficiently across most modern compilers. + + Thread locals have type intptr_t. + + Declaring a thread local variable 'foo': + GPR_TLS_DECL(foo); + Thread locals always have static scope. + + Declaring a thread local class variable 'foo': + GPR_TLS_CLASS_DECL(foo); + + Defining the thread local class variable: + GPR_TLS_CLASS_DEF(foo); + + Initializing a thread local (must be done at library initialization + time): + gpr_tls_init(&foo); + + Destroying a thread local: + gpr_tls_destroy(&foo); + + Setting a thread local (returns new_value): + gpr_tls_set(&foo, new_value); + + Accessing a thread local: + current_value = gpr_tls_get(&foo); + + ALL functions here may be implemented as macros. */ + +#ifdef GPR_GCC_TLS +#include "src/core/lib/gpr/tls_gcc.h" +#endif + +#ifdef GPR_MSVC_TLS +#include "src/core/lib/gpr/tls_msvc.h" +#endif + +#ifdef GPR_PTHREAD_TLS +#include "src/core/lib/gpr/tls_pthread.h" +#endif + +#endif /* GRPC_CORE_LIB_GPR_TLS_H */ diff --git a/src/core/lib/gpr/tls_gcc.h b/src/core/lib/gpr/tls_gcc.h new file mode 100644 index 0000000000..14c59eca55 --- /dev/null +++ b/src/core/lib/gpr/tls_gcc.h @@ -0,0 +1,50 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_TLS_GCC_H +#define GRPC_CORE_LIB_GPR_TLS_GCC_H + +#include + +#include + +/** Thread local storage based on gcc compiler primitives. + #include tls.h to use this - and see that file for documentation */ + +struct gpr_gcc_thread_local { + intptr_t value; +}; + +#define GPR_TLS_DECL(name) \ + static __thread struct gpr_gcc_thread_local name = {0} + +#define GPR_TLS_CLASS_DECL(name) \ + static __thread struct gpr_gcc_thread_local name + +#define GPR_TLS_CLASS_DEF(name) __thread struct gpr_gcc_thread_local name = {0} + +#define gpr_tls_init(tls) \ + do { \ + } while (0) +#define gpr_tls_destroy(tls) \ + do { \ + } while (0) +#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value)) +#define gpr_tls_get(tls) ((tls)->value) + +#endif /* GRPC_CORE_LIB_GPR_TLS_GCC_H */ diff --git a/src/core/lib/gpr/tls_msvc.h b/src/core/lib/gpr/tls_msvc.h new file mode 100644 index 0000000000..a6cc4174be --- /dev/null +++ b/src/core/lib/gpr/tls_msvc.h @@ -0,0 +1,50 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_TLS_MSVC_H +#define GRPC_CORE_LIB_GPR_TLS_MSVC_H + +/** Thread local storage based on ms visual c compiler primitives. + #include tls.h to use this - and see that file for documentation */ + +struct gpr_msvc_thread_local { + intptr_t value; +}; + +/** Use GPR_TLS_DECL to declare tls static variables outside a class */ +#define GPR_TLS_DECL(name) \ + static __declspec(thread) struct gpr_msvc_thread_local name = {0} + +/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class. + * GPR_TLS_CLASS_DEF needs to be called to define this member. */ +#define GPR_TLS_CLASS_DECL(name) \ + static __declspec(thread) struct gpr_msvc_thread_local name + +#define GPR_TLS_CLASS_DEF(name) \ + __declspec(thread) struct gpr_msvc_thread_local name = {0} + +#define gpr_tls_init(tls) \ + do { \ + } while (0) +#define gpr_tls_destroy(tls) \ + do { \ + } while (0) +#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value)) +#define gpr_tls_get(tls) ((tls)->value) + +#endif /* GRPC_CORE_LIB_GPR_TLS_MSVC_H */ diff --git a/src/core/lib/gpr/tls_pthread.cc b/src/core/lib/gpr/tls_pthread.cc index ebeef2a8c2..2e5b306909 100644 --- a/src/core/lib/gpr/tls_pthread.cc +++ b/src/core/lib/gpr/tls_pthread.cc @@ -20,7 +20,7 @@ #ifdef GPR_PTHREAD_TLS -#include +#include "src/core/lib/gpr/tls.h" intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value) { GPR_ASSERT(0 == pthread_setspecific(tls->key, (void*)value)); diff --git a/src/core/lib/gpr/tls_pthread.h b/src/core/lib/gpr/tls_pthread.h new file mode 100644 index 0000000000..9202653dcb --- /dev/null +++ b/src/core/lib/gpr/tls_pthread.h @@ -0,0 +1,54 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_TLS_PTHREAD_H +#define GRPC_CORE_LIB_GPR_TLS_PTHREAD_H + +#include /* for GPR_ASSERT */ +#include + +/** Thread local storage based on pthread library calls. + #include tls.h to use this - and see that file for documentation */ + +struct gpr_pthread_thread_local { + pthread_key_t key; +}; + +/** Use GPR_TLS_DECL to declare tls static variables outside a class */ +#define GPR_TLS_DECL(name) static struct gpr_pthread_thread_local name = {0} + +/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class. + * GPR_TLS_CLASS_DEF needs to be called to define this member. */ +#define GPR_TLS_CLASS_DECL(name) static struct gpr_pthread_thread_local name + +/** Use GPR_TLS_CLASS_DEF to declare tls static variable members of a class. + * GPR_TLS_CLASS_DEF needs to be called to define this member. */ +#define GPR_TLS_CLASS_DEF(name) struct gpr_pthread_thread_local name = {0} + +#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL)) +#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key) +#define gpr_tls_get(tls) ((intptr_t)pthread_getspecific((tls)->key)) +#ifdef __cplusplus +extern "C" { +#endif +intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value); +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_GPR_TLS_PTHREAD_H */ diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index ad274b839c..aa4ff67bc9 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -39,11 +39,11 @@ #include #include #include -#include #include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 416e8384b4..f82691dcc9 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -37,11 +37,11 @@ #include #include -#include #include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 1518348992..80ad9ebed2 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -39,10 +39,10 @@ #include #include -#include #include #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 3b79728055..cad417892f 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -34,11 +34,11 @@ #include #include #include -#include #include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/wakeup_fd_cv.h" diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 2e71482fb7..3d9a157627 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -22,8 +22,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/closure.h" typedef gpr_atm grpc_millis; diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 835dc9d0f7..30157e3d1d 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -25,11 +25,11 @@ #include #include #include -#include #include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/exec_ctx.h" #define MAX_DEPTH 2 diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 177bdec8df..015142fa91 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -29,10 +29,11 @@ #include #include #include -#include #include + #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/time_averaged_stats.h" #include "src/core/lib/iomgr/timer_heap.h" diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index e731e2139f..27f67054e4 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -28,11 +28,11 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" diff --git a/test/core/gpr/tls_test.cc b/test/core/gpr/tls_test.cc index 743b10f090..1ef253ed6f 100644 --- a/test/core/gpr/tls_test.cc +++ b/test/core/gpr/tls_test.cc @@ -21,9 +21,10 @@ #include #include #include -#include #include #include + +#include "src/core/lib/gpr/tls.h" #include "test/core/util/test_config.h" #define NUM_THREADS 100 diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index f4de5d7d8a..8f8d11ec59 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 44cd81a6a4..482f0cb24f 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -32,9 +32,9 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6873256dcd..e4e12f15df 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -926,10 +926,6 @@ include/grpc/support/sync_posix.h \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ -include/grpc/support/tls.h \ -include/grpc/support/tls_gcc.h \ -include/grpc/support/tls_msvc.h \ -include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/support/workaround_list.h diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 2c6505ddad..95be5bf31a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -927,10 +927,6 @@ include/grpc/support/sync_posix.h \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ -include/grpc/support/tls.h \ -include/grpc/support/tls_gcc.h \ -include/grpc/support/tls_msvc.h \ -include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/support/workaround_list.h \ src/core/ext/transport/inproc/inproc_transport.h \ @@ -962,6 +958,10 @@ src/core/lib/gpr/string.h \ src/core/lib/gpr/string_windows.h \ src/core/lib/gpr/thd_internal.h \ src/core/lib/gpr/time_precise.h \ +src/core/lib/gpr/tls.h \ +src/core/lib/gpr/tls_gcc.h \ +src/core/lib/gpr/tls_msvc.h \ +src/core/lib/gpr/tls_pthread.h \ src/core/lib/gpr/tmpfile.h \ src/core/lib/gprpp/abstract.h \ src/core/lib/gprpp/atomic.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index e2ccc78f56..92c557e214 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -866,10 +866,6 @@ include/grpc/support/sync_posix.h \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ -include/grpc/support/tls.h \ -include/grpc/support/tls_gcc.h \ -include/grpc/support/tls_msvc.h \ -include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/support/workaround_list.h diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 00057c2897..6fb3560b50 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -866,10 +866,6 @@ include/grpc/support/sync_posix.h \ include/grpc/support/sync_windows.h \ include/grpc/support/thd.h \ include/grpc/support/time.h \ -include/grpc/support/tls.h \ -include/grpc/support/tls_gcc.h \ -include/grpc/support/tls_msvc.h \ -include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ include/grpc/support/workaround_list.h \ src/core/README.md \ @@ -1116,7 +1112,11 @@ src/core/lib/gpr/time_posix.cc \ src/core/lib/gpr/time_precise.cc \ src/core/lib/gpr/time_precise.h \ src/core/lib/gpr/time_windows.cc \ +src/core/lib/gpr/tls.h \ +src/core/lib/gpr/tls_gcc.h \ +src/core/lib/gpr/tls_msvc.h \ src/core/lib/gpr/tls_pthread.cc \ +src/core/lib/gpr/tls_pthread.h \ src/core/lib/gpr/tmpfile.h \ src/core/lib/gpr/tmpfile_msys.cc \ src/core/lib/gpr/tmpfile_posix.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f61288b70d..423870ee29 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7920,10 +7920,6 @@ "include/grpc/support/sync_windows.h", "include/grpc/support/thd.h", "include/grpc/support/time.h", - "include/grpc/support/tls.h", - "include/grpc/support/tls_gcc.h", - "include/grpc/support/tls_msvc.h", - "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", @@ -7935,6 +7931,10 @@ "src/core/lib/gpr/string_windows.h", "src/core/lib/gpr/thd_internal.h", "src/core/lib/gpr/time_precise.h", + "src/core/lib/gpr/tls.h", + "src/core/lib/gpr/tls_gcc.h", + "src/core/lib/gpr/tls_msvc.h", + "src/core/lib/gpr/tls_pthread.h", "src/core/lib/gpr/tmpfile.h", "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/atomic.h", @@ -7969,10 +7969,6 @@ "include/grpc/support/sync_windows.h", "include/grpc/support/thd.h", "include/grpc/support/time.h", - "include/grpc/support/tls.h", - "include/grpc/support/tls_gcc.h", - "include/grpc/support/tls_msvc.h", - "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", @@ -7984,6 +7980,10 @@ "src/core/lib/gpr/string_windows.h", "src/core/lib/gpr/thd_internal.h", "src/core/lib/gpr/time_precise.h", + "src/core/lib/gpr/tls.h", + "src/core/lib/gpr/tls_gcc.h", + "src/core/lib/gpr/tls_msvc.h", + "src/core/lib/gpr/tls_pthread.h", "src/core/lib/gpr/tmpfile.h", "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/atomic.h", -- cgit v1.2.3 From ae376bf9d982892eba5b052b87f88e24b1bb0677 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 25 Jan 2018 22:54:02 -0800 Subject: Privatize host_port.h; was not used in any wrapped language implementation --- BUILD | 2 +- CMakeLists.txt | 4 -- Makefile | 4 -- build.yaml | 2 +- gRPC-C++.podspec | 2 + gRPC-Core.podspec | 3 +- grpc.def | 2 - grpc.gemspec | 2 +- include/grpc/module.modulemap | 1 - include/grpc/support/host_port.h | 51 ---------------------- package.xml | 2 +- src/core/ext/filters/client_channel/http_proxy.cc | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 2 +- .../ext/filters/client_channel/parse_address.cc | 3 +- .../resolver/dns/c_ares/dns_resolver_ares.cc | 2 +- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 2 +- .../resolver/dns/native/dns_resolver.cc | 2 +- .../client_channel/resolver/fake/fake_resolver.cc | 2 +- .../resolver/sockaddr/sockaddr_resolver.cc | 2 +- .../transport/cronet/transport/cronet_transport.cc | 2 +- src/core/lib/gpr/host_port.cc | 3 +- src/core/lib/gpr/host_port.h | 51 ++++++++++++++++++++++ src/core/lib/iomgr/resolve_address_posix.cc | 3 +- src/core/lib/iomgr/resolve_address_uv.cc | 2 +- src/core/lib/iomgr/resolve_address_windows.cc | 3 +- src/core/lib/iomgr/sockaddr_utils.cc | 2 +- src/core/lib/iomgr/socket_utils_common_posix.cc | 3 +- .../lib/security/transport/security_connector.cc | 2 +- .../CoreCronetEnd2EndTests.mm | 2 +- .../tests/CronetUnitTests/CronetUnitTests.m | 1 + src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 -- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 7 --- test/core/bad_ssl/bad_ssl_test.cc | 3 +- test/core/client_channel/lb_policies_test.cc | 2 +- test/core/end2end/bad_server_response_test.cc | 2 +- test/core/end2end/connection_refused_test.cc | 2 +- test/core/end2end/dualstack_socket_test.cc | 2 +- test/core/end2end/fixtures/h2_census.cc | 3 +- test/core/end2end/fixtures/h2_compress.cc | 3 +- test/core/end2end/fixtures/h2_fakesec.cc | 3 +- test/core/end2end/fixtures/h2_full+pipe.cc | 3 +- test/core/end2end/fixtures/h2_full+trace.cc | 3 +- test/core/end2end/fixtures/h2_full+workarounds.cc | 3 +- test/core/end2end/fixtures/h2_full.cc | 3 +- test/core/end2end/fixtures/h2_http_proxy.cc | 3 +- test/core/end2end/fixtures/h2_load_reporting.cc | 3 +- test/core/end2end/fixtures/h2_oauth2.cc | 3 +- test/core/end2end/fixtures/h2_proxy.cc | 3 +- test/core/end2end/fixtures/h2_ssl.cc | 2 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 2 +- test/core/end2end/fixtures/h2_uds.cc | 2 +- test/core/end2end/fixtures/http_proxy_fixture.cc | 2 +- test/core/end2end/fixtures/inproc.cc | 3 +- test/core/end2end/fixtures/proxy.cc | 2 +- test/core/end2end/h2_ssl_cert_test.cc | 2 +- test/core/end2end/invalid_call_argument_test.cc | 2 +- test/core/fling/fling_stream_test.cc | 3 +- test/core/fling/fling_test.cc | 3 +- test/core/fling/server.cc | 3 +- test/core/gpr/host_port_test.cc | 3 +- test/core/memory_usage/memory_usage_test.cc | 3 +- test/core/memory_usage/server.cc | 3 +- .../num_external_connectivity_watchers_test.cc | 2 +- test/core/surface/public_headers_must_be_c89.c | 3 -- test/core/surface/sequential_connectivity_test.cc | 2 +- test/core/surface/server_chttp2_test.cc | 3 +- test/core/surface/server_test.cc | 3 +- test/core/util/reconnect_server.cc | 3 +- test/core/util/test_tcp_server.cc | 3 +- test/cpp/grpclb/grpclb_test.cc | 2 +- test/cpp/interop/interop_test.cc | 2 +- test/cpp/naming/resolver_component_test.cc | 2 +- test/cpp/qps/client_sync.cc | 2 +- test/cpp/qps/driver.cc | 2 +- test/cpp/qps/qps_worker.cc | 2 +- test/cpp/qps/server_async.cc | 2 +- test/cpp/qps/server_sync.cc | 2 +- tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core | 1 - tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 4 +- 82 files changed, 153 insertions(+), 148 deletions(-) delete mode 100644 include/grpc/support/host_port.h create mode 100644 src/core/lib/gpr/host_port.h (limited to 'BUILD') diff --git a/BUILD b/BUILD index 0a8be79e8a..6c801e2bed 100644 --- a/BUILD +++ b/BUILD @@ -69,7 +69,6 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", - "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", @@ -502,6 +501,7 @@ grpc_cc_library( "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index c557e9469a..d99c5032e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -706,7 +706,6 @@ foreach(_hdr include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h - include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -2500,7 +2499,6 @@ foreach(_hdr include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h - include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -2984,7 +2982,6 @@ foreach(_hdr include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h - include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -3714,7 +3711,6 @@ foreach(_hdr include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h - include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h diff --git a/Makefile b/Makefile index 39a94d8c55..f60077b88a 100644 --- a/Makefile +++ b/Makefile @@ -2899,7 +2899,6 @@ PUBLIC_HEADERS_C += \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ - include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -4631,7 +4630,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ - include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -5120,7 +5118,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ - include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -5839,7 +5836,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ - include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/build.yaml b/build.yaml index d4d5af1371..37021e64d6 100644 --- a/build.yaml +++ b/build.yaml @@ -82,7 +82,6 @@ filegroups: - include/grpc/support/avl.h - include/grpc/support/cmdline.h - include/grpc/support/cpu.h - - include/grpc/support/host_port.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h @@ -104,6 +103,7 @@ filegroups: - src/core/lib/gpr/arena.h - src/core/lib/gpr/env.h - src/core/lib/gpr/fork.h + - src/core/lib/gpr/host_port.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - src/core/lib/gpr/spinlock.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 55f33d9aef..3022c3d6c4 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -205,6 +205,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -451,6 +452,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7ee7bb52d2..c969ac149c 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -117,7 +117,6 @@ Pod::Spec.new do |s| 'include/grpc/support/avl.h', 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', - 'include/grpc/support/host_port.h', 'include/grpc/support/log.h', 'include/grpc/support/log_windows.h', 'include/grpc/support/port_platform.h', @@ -196,6 +195,7 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -725,6 +725,7 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', diff --git a/grpc.def b/grpc.def index 2bec47480a..544b509293 100644 --- a/grpc.def +++ b/grpc.def @@ -201,8 +201,6 @@ EXPORTS gpr_cmdline_usage_string gpr_cpu_num_cores gpr_cpu_current_cpu - gpr_join_host_port - gpr_split_host_port gpr_log_severity_string gpr_log gpr_log_message diff --git a/grpc.gemspec b/grpc.gemspec index 41e56d0bf1..be4a0ddc05 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -52,7 +52,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/avl.h ) s.files += %w( include/grpc/support/cmdline.h ) s.files += %w( include/grpc/support/cpu.h ) - s.files += %w( include/grpc/support/host_port.h ) s.files += %w( include/grpc/support/log.h ) s.files += %w( include/grpc/support/log_windows.h ) s.files += %w( include/grpc/support/port_platform.h ) @@ -86,6 +85,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/arena.h ) s.files += %w( src/core/lib/gpr/env.h ) s.files += %w( src/core/lib/gpr/fork.h ) + s.files += %w( src/core/lib/gpr/host_port.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index d23072f556..2f8c526bab 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -7,7 +7,6 @@ framework module grpc { header "support/avl.h" header "support/cmdline.h" header "support/cpu.h" - header "support/host_port.h" header "support/log.h" header "support/log_windows.h" header "support/port_platform.h" diff --git a/include/grpc/support/host_port.h b/include/grpc/support/host_port.h deleted file mode 100644 index 9805811bfb..0000000000 --- a/include/grpc/support/host_port.h +++ /dev/null @@ -1,51 +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. - * - */ - -#ifndef GRPC_SUPPORT_HOST_PORT_H -#define GRPC_SUPPORT_HOST_PORT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Given a host and port, creates a newly-allocated string of the form - "host:port" or "[ho:st]:port", depending on whether the host contains colons - like an IPv6 literal. If the host is already bracketed, then additional - brackets will not be added. - - Usage is similar to gpr_asprintf: returns the number of bytes written - (excluding the final '\0'), and *out points to a string which must later be - destroyed using gpr_free(). - - In the unlikely event of an error, returns -1 and sets *out to NULL. */ -GPRAPI int gpr_join_host_port(char** out, const char* host, int port); - -/** Given a name in the form "host:port" or "[ho:st]:port", split into hostname - and port number, into newly allocated strings, which must later be - destroyed using gpr_free(). - Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on - failure. */ -GPRAPI int gpr_split_host_port(const char* name, char** host, char** port); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_HOST_PORT_H */ diff --git a/package.xml b/package.xml index 3f529a2096..0cc0211781 100644 --- a/package.xml +++ b/package.xml @@ -59,7 +59,6 @@ - @@ -93,6 +92,7 @@ + diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 7c5f79fb30..d42376413d 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -31,6 +30,7 @@ #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/channel/channel_args.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/slice/b64.h" 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 1709e5622e..5e24bdd4e7 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 @@ -87,7 +87,6 @@ #include #include #include -#include #include #include @@ -106,6 +105,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index c3309e36a3..4b6905eaa3 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -26,9 +26,10 @@ #endif #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #ifdef GRPC_HAVE_UNIX_SOCKET 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 6ba5f932f0..3ade00550b 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 @@ -25,7 +25,6 @@ #include #include -#include #include #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" @@ -35,6 +34,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.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/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" 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 2b35bdb605..03bd2acf6b 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 @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/executor.h" 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 62f03d52c0..2f9a964628 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 @@ -22,7 +22,6 @@ #include #include -#include #include #include "src/core/ext/filters/client_channel/lb_policy_registry.h" @@ -30,6 +29,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.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/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" 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 eaa5e6ac49..72a1dece82 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 @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -32,6 +31,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 99ad78e23c..784935eb20 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -30,6 +29,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 5b1c6ab3f9..6301d69faf 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -21,13 +21,13 @@ #include #include #include -#include #include #include #include #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/lib/gpr/host_port.cc b/src/core/lib/gpr/host_port.cc index 29178279d3..0776727906 100644 --- a/src/core/lib/gpr/host_port.cc +++ b/src/core/lib/gpr/host_port.cc @@ -16,13 +16,14 @@ * */ -#include +#include "src/core/lib/gpr/host_port.h" #include #include #include #include + #include "src/core/lib/gpr/string.h" int gpr_join_host_port(char** out, const char* host, int port) { diff --git a/src/core/lib/gpr/host_port.h b/src/core/lib/gpr/host_port.h new file mode 100644 index 0000000000..ee71327bcb --- /dev/null +++ b/src/core/lib/gpr/host_port.h @@ -0,0 +1,51 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_HOST_PORT_H +#define GRPC_CORE_LIB_GPR_HOST_PORT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Given a host and port, creates a newly-allocated string of the form + "host:port" or "[ho:st]:port", depending on whether the host contains colons + like an IPv6 literal. If the host is already bracketed, then additional + brackets will not be added. + + Usage is similar to gpr_asprintf: returns the number of bytes written + (excluding the final '\0'), and *out points to a string which must later be + destroyed using gpr_free(). + + In the unlikely event of an error, returns -1 and sets *out to NULL. */ +int gpr_join_host_port(char** out, const char* host, int port); + +/** Given a name in the form "host:port" or "[ho:st]:port", split into hostname + and port number, into newly allocated strings, which must later be + destroyed using gpr_free(). + Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on + failure. */ +int gpr_split_host_port(const char* name, char** host, char** port); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_GPR_HOST_PORT_H */ diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index 176caee490..7ed2862903 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -27,12 +27,13 @@ #include #include -#include #include #include #include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" diff --git a/src/core/lib/iomgr/resolve_address_uv.cc b/src/core/lib/iomgr/resolve_address_uv.cc index 3eab04f3de..7252555bd0 100644 --- a/src/core/lib/iomgr/resolve_address_uv.cc +++ b/src/core/lib/iomgr/resolve_address_uv.cc @@ -22,11 +22,11 @@ #include #include -#include #include #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc index e44ab396b3..e875d77fd8 100644 --- a/src/core/lib/iomgr/resolve_address_windows.cc +++ b/src/core/lib/iomgr/resolve_address_windows.cc @@ -28,12 +28,13 @@ #include #include -#include #include #include #include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index 71e3e38624..ac97af4dee 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -23,11 +23,11 @@ #include #include -#include #include #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 5068a8081d..d02d77eb02 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -36,10 +36,11 @@ #include #include -#include #include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index 1d962f94b2..fd632bdbab 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -31,6 +30,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.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/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm index 16940a4917..d91b5cf99e 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm @@ -34,12 +34,12 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/security/credentials/credentials.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/gpr/tmpfile.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m index 09ee062596..b5448d22ce 100644 --- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m +++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m @@ -32,6 +32,7 @@ #import "src/core/lib/channel/channel_args.h" #import "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #import "src/core/lib/gpr/string.h" #import "src/core/lib/gpr/tmpfile.h" #import "test/core/end2end/data/ssl_test_data.h" diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 5473c52bb5..df80be33cd 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -224,8 +224,6 @@ gpr_cmdline_destroy_type gpr_cmdline_destroy_import; gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; gpr_cpu_num_cores_type gpr_cpu_num_cores_import; gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; -gpr_join_host_port_type gpr_join_host_port_import; -gpr_split_host_port_type gpr_split_host_port_import; gpr_log_severity_string_type gpr_log_severity_string_import; gpr_log_type gpr_log_import; gpr_log_message_type gpr_log_message_import; @@ -497,8 +495,6 @@ void grpc_rb_load_imports(HMODULE library) { gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string"); gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); - gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port"); - gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port"); gpr_log_severity_string_import = (gpr_log_severity_string_type) GetProcAddress(library, "gpr_log_severity_string"); gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index d701d2f571..ddb0ff6a4d 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -652,12 +651,6 @@ extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import; typedef unsigned(*gpr_cpu_current_cpu_type)(void); extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; #define gpr_cpu_current_cpu gpr_cpu_current_cpu_import -typedef int(*gpr_join_host_port_type)(char** out, const char* host, int port); -extern gpr_join_host_port_type gpr_join_host_port_import; -#define gpr_join_host_port gpr_join_host_port_import -typedef int(*gpr_split_host_port_type)(const char* name, char** host, char** port); -extern gpr_split_host_port_type gpr_split_host_port_import; -#define gpr_split_host_port gpr_split_host_port_import typedef const char*(*gpr_log_severity_string_type)(gpr_log_severity severity); extern gpr_log_severity_string_type gpr_log_severity_string_import; #define gpr_log_severity_string gpr_log_severity_string_import diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8a7960b5ed..8aec94fd99 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -22,11 +22,12 @@ #include #include #include -#include #include #include #include + #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc index 716c63b9d0..a632bef85b 100644 --- a/test/core/client_channel/lb_policies_test.cc +++ b/test/core/client_channel/lb_policies_test.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index a8e5e291c8..2b98620164 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -27,10 +27,10 @@ #include #include #include -#include #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index ca6d17e7c8..ff830b47cd 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -20,11 +20,11 @@ #include #include -#include #include #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index bb30547cd2..2dc72b885f 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -25,10 +25,10 @@ #include #include -#include #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 75c80aa1ff..2e3bfac586 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -21,16 +21,17 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 3625afefcd..2e8ca806c9 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -21,16 +21,17 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 87d4668d50..bbf65fcd24 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -22,9 +22,10 @@ #include #include -#include #include + #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index b080591e85..fd001953b2 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -26,15 +26,16 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 7104fbc581..c42ef2c343 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -26,16 +26,17 @@ #endif #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index 237841d185..1ae54163e1 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -21,16 +21,17 @@ #include #include -#include #include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index 6d15c28662..c855205889 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -21,15 +21,16 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index e8e81f0930..5a2ceb759e 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -21,17 +21,18 @@ #include #include -#include #include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/http_proxy_fixture.h" diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc index fda5f4b052..61820c29dd 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.cc +++ b/test/core/end2end/fixtures/h2_load_reporting.cc @@ -21,17 +21,18 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 5fed4434de..795e94a9e8 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -22,9 +22,10 @@ #include #include -#include #include + #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index 295654cb6a..5a3aef4045 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -21,15 +21,16 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 8c5c8a2f3f..bbcc88e4f3 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -22,11 +22,11 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.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/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index 3f0646cf0f..6b0b891b18 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -22,11 +22,11 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.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/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index 1944dd84a3..a27f897d61 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 8ec97df3e4..bda4a11942 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/closure.h" diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index b748fbf09a..f690d22cd3 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -21,15 +21,16 @@ #include #include -#include #include #include #include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index b1698c804c..58d542beac 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -21,12 +21,12 @@ #include #include -#include #include #include #include #include +#include "src/core/lib/gpr/host_port.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 3383d6d5d1..96009aec4a 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -22,11 +22,11 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.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/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index cb6b4c08ef..d2b26e7131 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -23,9 +23,9 @@ #include #include -#include #include +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index b5a5ce816e..6b29486f22 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -20,9 +20,10 @@ #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3792e45c42..ceb9851bc9 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -20,9 +20,10 @@ #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index f3a8a1ccf8..328bd4edbd 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -31,9 +31,10 @@ #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/grpc_profiler.h" diff --git a/test/core/gpr/host_port_test.cc b/test/core/gpr/host_port_test.cc index 42dd56524f..b5d88b2b01 100644 --- a/test/core/gpr/host_port_test.cc +++ b/test/core/gpr/host_port_test.cc @@ -19,8 +19,9 @@ #include #include -#include #include + +#include "src/core/lib/gpr/host_port.h" #include "test/core/util/test_config.h" static void join_host_port_expect(const char* host, int port, diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index fb6d290130..f6316bda0b 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -20,9 +20,10 @@ #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 60ebcece3e..bca4486163 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -31,9 +31,10 @@ #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/memory_counters.h" #include "test/core/util/port.h" diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 9cdd299ae3..e48fd7fcf2 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -19,11 +19,11 @@ #include #include #include -#include #include #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index f4de5d7d8a..c13ea31b2d 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -266,8 +265,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_cmdline_usage_string); printf("%lx", (unsigned long) gpr_cpu_num_cores); printf("%lx", (unsigned long) gpr_cpu_current_cpu); - printf("%lx", (unsigned long) gpr_join_host_port); - printf("%lx", (unsigned long) gpr_split_host_port); printf("%lx", (unsigned long) gpr_log_severity_string); printf("%lx", (unsigned long) gpr_log); printf("%lx", (unsigned long) gpr_log_message); diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index ac49bd9823..1ac0a5ee13 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -19,11 +19,11 @@ #include #include #include -#include #include #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index 96eaa6a7a9..f0412d01d9 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -19,9 +19,10 @@ #include #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/tsi/fake_transport_security.h" diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index 969b8cb11b..3b08efb563 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -19,9 +19,10 @@ #include #include #include -#include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index bcafc4e898..b5a7749385 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -20,11 +20,12 @@ #include #include -#include #include #include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 5f6af4e707..b1b5297f29 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -22,11 +22,12 @@ #include #include -#include #include #include #include #include + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index d241594af1..4a9fd7ce76 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.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/gpr/tmpfile.h" #include "src/core/lib/iomgr/sockaddr.h" diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index 563b7abb5e..ae155b65f9 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -31,12 +31,12 @@ #include #include -#include #include #include #include "test/core/util/port.h" #include "test/cpp/util/test_config.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 8b5523f01a..aad2fa5f75 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -38,6 +37,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.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/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index a2ddbeb508..8c1d9417fa 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -30,10 +30,10 @@ #include #include #include -#include #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/client.h" diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index a809a27e3c..4e0d266d77 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -27,11 +27,11 @@ #include #include #include -#include #include #include #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 4c9ab0ea43..215a7bfbc9 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -32,9 +32,9 @@ #include #include #include -#include #include +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/services.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 72ae772147..b88b88445c 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -32,9 +32,9 @@ #include #include #include -#include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/core/util/test_config.h" diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index ea89a30e2e..19cbb53445 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -24,8 +24,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/server.h" #include "test/cpp/qps/usage_timer.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6873256dcd..fe08ce6c0d 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -913,7 +913,6 @@ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ -include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 2c6505ddad..1d419e7ee4 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -914,7 +914,6 @@ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ -include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -955,6 +954,7 @@ src/core/lib/debug/trace.h \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/env.h \ src/core/lib/gpr/fork.h \ +src/core/lib/gpr/host_port.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index e2ccc78f56..a99b36c972 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -853,7 +853,6 @@ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ -include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 00057c2897..4549eeced3 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -853,7 +853,6 @@ include/grpc/support/atm_windows.h \ include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ -include/grpc/support/host_port.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -1086,6 +1085,7 @@ src/core/lib/gpr/env_windows.cc \ src/core/lib/gpr/fork.cc \ src/core/lib/gpr/fork.h \ src/core/lib/gpr/host_port.cc \ +src/core/lib/gpr/host_port.h \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f61288b70d..3d5d29c49c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7907,7 +7907,6 @@ "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", - "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", @@ -7928,6 +7927,7 @@ "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -7956,7 +7956,6 @@ "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", - "include/grpc/support/host_port.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", @@ -7977,6 +7976,7 @@ "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", -- cgit v1.2.3 From d4d0a30c6f569e031d0bfaa31f0410b855f362a3 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 25 Jan 2018 13:24:03 -0800 Subject: Privatize useful.h and avl.h --- BUILD | 4 +- CMakeLists.txt | 8 -- Makefile | 8 -- build.yaml | 4 +- gRPC-C++.podspec | 4 + gRPC-Core.podspec | 6 +- grpc.def | 8 -- grpc.gemspec | 4 +- include/grpc++/server_builder.h | 1 - include/grpc/module.modulemap | 2 - include/grpc/support/avl.h | 102 --------------------- include/grpc/support/useful.h | 65 ------------- package.xml | 4 +- .../ext/filters/client_channel/client_channel.cc | 1 - .../lb_policy/grpclb/grpclb_client_stats.cc | 1 - .../dns/c_ares/grpc_ares_ev_driver_posix.cc | 1 - .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 1 - .../ext/filters/client_channel/retry_throttle.cc | 3 +- src/core/ext/filters/client_channel/subchannel.cc | 1 - .../ext/filters/client_channel/subchannel_index.cc | 2 +- src/core/ext/transport/chttp2/alpn/alpn.cc | 3 +- .../ext/transport/chttp2/server/chttp2_server.cc | 1 - .../transport/chttp2/transport/chttp2_transport.cc | 1 - .../ext/transport/chttp2/transport/flow_control.cc | 1 - .../ext/transport/chttp2/transport/flow_control.h | 2 +- .../ext/transport/chttp2/transport/frame_data.cc | 1 - .../transport/chttp2/transport/frame_settings.cc | 1 - .../transport/chttp2/transport/hpack_encoder.cc | 1 - .../ext/transport/chttp2/transport/hpack_parser.cc | 1 - .../transport/chttp2/transport/http2_settings.cc | 2 +- .../ext/transport/chttp2/transport/stream_map.cc | 1 - .../transport/cronet/transport/cronet_transport.cc | 1 - src/core/lib/backoff/backoff.cc | 2 +- src/core/lib/channel/channel_args.cc | 2 +- src/core/lib/compression/compression.cc | 2 +- src/core/lib/compression/compression_internal.cc | 2 +- src/core/lib/compression/compression_ruby.cc | 1 - src/core/lib/debug/stats.cc | 2 +- src/core/lib/debug/stats_data.cc | 3 +- src/core/lib/gpr/arena.cc | 1 - src/core/lib/gpr/atm.cc | 3 +- src/core/lib/gpr/avl.cc | 5 +- src/core/lib/gpr/avl.h | 92 +++++++++++++++++++ src/core/lib/gpr/cpu_posix.cc | 3 +- src/core/lib/gpr/env_linux.cc | 2 +- src/core/lib/gpr/env_windows.cc | 8 +- src/core/lib/gpr/fork.cc | 2 +- src/core/lib/gpr/string.cc | 3 +- src/core/lib/gpr/thd_posix.cc | 2 +- src/core/lib/gpr/useful.h | 65 +++++++++++++ src/core/lib/http/format_request.cc | 1 - src/core/lib/http/httpcli.cc | 1 - src/core/lib/http/parser.cc | 3 +- src/core/lib/iomgr/error.cc | 2 +- src/core/lib/iomgr/ev_epoll1_linux.cc | 2 +- src/core/lib/iomgr/ev_epollex_linux.cc | 2 +- src/core/lib/iomgr/ev_epollsig_linux.cc | 2 +- src/core/lib/iomgr/ev_poll_posix.cc | 2 +- src/core/lib/iomgr/ev_posix.cc | 2 +- src/core/lib/iomgr/executor.cc | 2 +- src/core/lib/iomgr/fork_posix.cc | 1 - src/core/lib/iomgr/iocp_windows.cc | 1 - src/core/lib/iomgr/iomgr.cc | 2 +- src/core/lib/iomgr/resolve_address_posix.cc | 3 +- src/core/lib/iomgr/resolve_address_uv.cc | 2 +- src/core/lib/iomgr/resource_quota.cc | 2 +- src/core/lib/iomgr/socket_factory_posix.cc | 2 +- src/core/lib/iomgr/socket_mutator.cc | 6 +- src/core/lib/iomgr/tcp_client_windows.cc | 1 - src/core/lib/iomgr/tcp_posix.cc | 2 +- src/core/lib/iomgr/tcp_server_posix.cc | 1 - src/core/lib/iomgr/tcp_windows.cc | 2 +- src/core/lib/iomgr/timer_generic.cc | 3 +- src/core/lib/iomgr/timer_heap.cc | 3 +- src/core/lib/iomgr/unix_sockets_posix.cc | 3 +- src/core/lib/iomgr/wakeup_fd_cv.cc | 3 +- .../lib/security/credentials/jwt/jwt_verifier.cc | 1 - src/core/lib/slice/b64.cc | 2 +- src/core/lib/slice/slice_buffer.cc | 2 +- src/core/lib/surface/call.cc | 2 +- src/core/lib/surface/channel_init.cc | 1 - src/core/lib/surface/server.cc | 1 - src/core/lib/transport/bdp_estimator.cc | 2 +- src/core/lib/transport/metadata.h | 2 +- src/core/lib/transport/pid_controller.cc | 3 +- src/core/lib/transport/transport_op_string.cc | 1 - src/core/tsi/fake_transport_security.cc | 3 +- src/core/tsi/ssl_transport_security.cc | 1 - src/cpp/client/channel_cc.cc | 1 - src/cpp/server/server_builder.cc | 2 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 16 ---- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 25 ----- test/core/backoff/backoff_test.cc | 1 - test/core/bad_ssl/servers/alpn.cc | 2 +- test/core/bad_ssl/servers/cert.cc | 1 - test/core/channel/channel_args_test.cc | 2 +- test/core/compression/algorithm_test.cc | 1 - test/core/compression/compression_test.cc | 2 +- test/core/compression/message_compress_test.cc | 2 +- test/core/end2end/cq_verifier.cc | 1 - test/core/end2end/fixtures/h2_census.cc | 1 - test/core/end2end/fixtures/h2_compress.cc | 1 - test/core/end2end/fixtures/h2_full+pipe.cc | 2 +- test/core/end2end/fixtures/h2_full+trace.cc | 2 +- test/core/end2end/fixtures/h2_full+workarounds.cc | 2 +- test/core/end2end/fixtures/h2_full.cc | 2 +- test/core/end2end/fixtures/h2_http_proxy.cc | 2 +- test/core/end2end/fixtures/h2_load_reporting.cc | 2 +- test/core/end2end/fixtures/h2_proxy.cc | 2 +- test/core/end2end/fixtures/h2_sockpair+trace.cc | 2 +- test/core/end2end/fixtures/h2_sockpair.cc | 2 +- test/core/end2end/fixtures/h2_sockpair_1byte.cc | 2 +- test/core/end2end/fixtures/h2_uds.cc | 2 +- test/core/end2end/fixtures/http_proxy_fixture.cc | 1 - test/core/end2end/fixtures/inproc.cc | 1 - test/core/end2end/fixtures/proxy.cc | 2 +- test/core/end2end/tests/authority_not_supported.cc | 1 - test/core/end2end/tests/bad_hostname.cc | 1 - test/core/end2end/tests/bad_ping.cc | 2 +- test/core/end2end/tests/binary_metadata.cc | 1 - test/core/end2end/tests/call_creds.cc | 2 +- test/core/end2end/tests/cancel_after_accept.cc | 1 - .../core/end2end/tests/cancel_after_client_done.cc | 3 +- test/core/end2end/tests/cancel_after_invoke.cc | 3 +- test/core/end2end/tests/cancel_after_round_trip.cc | 1 - test/core/end2end/tests/cancel_before_invoke.cc | 1 - test/core/end2end/tests/cancel_in_a_vacuum.cc | 3 +- test/core/end2end/tests/cancel_with_status.cc | 1 - test/core/end2end/tests/compressed_payload.cc | 1 - test/core/end2end/tests/default_host.cc | 1 - test/core/end2end/tests/disappearing_server.cc | 1 - test/core/end2end/tests/empty_batch.cc | 1 - test/core/end2end/tests/filter_call_init_fails.cc | 1 - test/core/end2end/tests/filter_causes_close.cc | 1 - test/core/end2end/tests/filter_latency.cc | 1 - test/core/end2end/tests/filter_status_code.cc | 1 - .../core/end2end/tests/graceful_server_shutdown.cc | 1 - test/core/end2end/tests/high_initial_seqno.cc | 1 - test/core/end2end/tests/hpack_size.cc | 2 +- test/core/end2end/tests/idempotent_request.cc | 2 +- test/core/end2end/tests/invoke_large_request.cc | 3 +- test/core/end2end/tests/keepalive_timeout.cc | 3 +- test/core/end2end/tests/large_metadata.cc | 1 - test/core/end2end/tests/load_reporting_hook.cc | 1 - test/core/end2end/tests/max_concurrent_streams.cc | 1 - test/core/end2end/tests/max_connection_age.cc | 2 +- test/core/end2end/tests/max_connection_idle.cc | 2 +- test/core/end2end/tests/max_message_length.cc | 1 - test/core/end2end/tests/negative_deadline.cc | 1 - test/core/end2end/tests/network_status_change.cc | 1 - test/core/end2end/tests/no_logging.cc | 1 - test/core/end2end/tests/no_op.cc | 1 - test/core/end2end/tests/payload.cc | 1 - test/core/end2end/tests/ping.cc | 2 +- test/core/end2end/tests/ping_pong_streaming.cc | 1 - test/core/end2end/tests/proxy_auth.cc | 1 - test/core/end2end/tests/registered_call.cc | 2 +- test/core/end2end/tests/request_with_flags.cc | 3 +- test/core/end2end/tests/request_with_payload.cc | 1 - test/core/end2end/tests/resource_quota_server.cc | 2 +- test/core/end2end/tests/server_finishes_request.cc | 1 - test/core/end2end/tests/shutdown_finishes_calls.cc | 1 - test/core/end2end/tests/shutdown_finishes_tags.cc | 1 - .../core/end2end/tests/simple_cacheable_request.cc | 1 - test/core/end2end/tests/simple_delayed_request.cc | 1 - test/core/end2end/tests/simple_metadata.cc | 1 - test/core/end2end/tests/simple_request.cc | 1 - .../tests/stream_compression_compressed_payload.cc | 1 - .../end2end/tests/stream_compression_payload.cc | 1 - .../stream_compression_ping_pong_streaming.cc | 2 +- .../core/end2end/tests/streaming_error_response.cc | 1 - test/core/end2end/tests/trailing_metadata.cc | 1 - .../end2end/tests/workaround_cronet_compression.cc | 1 - test/core/end2end/tests/write_buffering.cc | 1 - test/core/end2end/tests/write_buffering_at_end.cc | 1 - test/core/fling/client.cc | 3 +- test/core/gpr/arena_test.cc | 2 +- test/core/gpr/avl_test.cc | 4 +- test/core/gpr/cmdline_test.cc | 3 +- test/core/gpr/mpscq_test.cc | 3 +- test/core/gpr/string_test.cc | 2 +- test/core/gpr/useful_test.cc | 3 +- test/core/http/parser_test.cc | 3 +- test/core/iomgr/combiner_test.cc | 2 +- test/core/iomgr/endpoint_pair_test.cc | 3 +- test/core/iomgr/endpoint_tests.cc | 2 +- test/core/iomgr/error_test.cc | 1 - test/core/iomgr/ev_epollsig_linux_test.cc | 2 +- test/core/iomgr/pollset_set_test.cc | 2 +- test/core/iomgr/resolve_address_posix_test.cc | 2 +- test/core/iomgr/socket_utils_test.cc | 3 +- test/core/iomgr/tcp_posix_test.cc | 2 +- test/core/iomgr/timer_heap_test.cc | 2 +- test/core/iomgr/udp_server_test.cc | 2 +- test/core/iomgr/wakeup_fd_cv_test.cc | 1 - test/core/json/json_rewrite_test.cc | 2 +- test/core/json/json_stream_error_test.cc | 1 - test/core/json/json_test.cc | 2 +- test/core/memory_usage/client.cc | 2 +- .../core/network_benchmarks/low_level_ping_pong.cc | 3 +- test/core/security/secure_endpoint_test.cc | 2 +- test/core/security/security_connector_test.cc | 1 - test/core/slice/slice_string_helpers_test.cc | 1 - test/core/surface/completion_queue_test.cc | 2 +- .../surface/completion_queue_threading_test.cc | 3 +- test/core/surface/public_headers_must_be_c89.c | 10 -- test/core/transport/bdp_estimator_test.cc | 4 +- test/core/transport/byte_stream_test.cc | 2 +- test/core/transport/pid_controller_test.cc | 2 +- test/core/transport/timeout_encoding_test.cc | 3 +- test/core/tsi/transport_security_test.cc | 2 +- test/core/util/histogram.cc | 5 +- test/core/util/slice_splitter.cc | 3 +- test/core/util/test_config.cc | 2 +- test/core/util/trickle_endpoint.cc | 3 +- test/cpp/common/channel_arguments_test.cc | 2 +- test/cpp/interop/client.cc | 1 - test/cpp/interop/http2_client.cc | 2 +- test/cpp/interop/interop_client.cc | 1 - test/cpp/interop/interop_server.cc | 1 - test/cpp/microbenchmarks/bm_pollset.cc | 2 +- tools/doxygen/Doxyfile.c++ | 2 - tools/doxygen/Doxyfile.c++.internal | 4 +- tools/doxygen/Doxyfile.core | 2 - tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 8 +- 226 files changed, 341 insertions(+), 478 deletions(-) delete mode 100644 include/grpc/support/avl.h delete mode 100644 include/grpc/support/useful.h create mode 100644 src/core/lib/gpr/avl.h create mode 100644 src/core/lib/gpr/useful.h (limited to 'BUILD') diff --git a/BUILD b/BUILD index 1779575c42..55fc2f0ff2 100644 --- a/BUILD +++ b/BUILD @@ -66,7 +66,6 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/atm_gcc_atomic.h", "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", - "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", @@ -86,7 +85,6 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/tls_gcc.h", "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", - "include/grpc/support/useful.h", ] GRPC_PUBLIC_HDRS = [ @@ -501,8 +499,10 @@ grpc_cc_library( hdrs = [ "src/core/lib/profiling/timers.h", "src/core/lib/gpr/arena.h", + "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", + "src/core/lib/gpr/useful.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1158cef5..782bd587f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -704,7 +704,6 @@ foreach(_hdr include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h - include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h @@ -724,7 +723,6 @@ foreach(_hdr include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h - include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -2494,7 +2492,6 @@ foreach(_hdr include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h - include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h @@ -2514,7 +2511,6 @@ foreach(_hdr include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h - include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -2969,7 +2965,6 @@ foreach(_hdr include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h - include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h @@ -2989,7 +2984,6 @@ foreach(_hdr include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h - include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -3700,7 +3694,6 @@ foreach(_hdr include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h - include/grpc/support/avl.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/host_port.h @@ -3720,7 +3713,6 @@ foreach(_hdr include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h - include/grpc/support/useful.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h diff --git a/Makefile b/Makefile index 37934a6791..3de7410fa0 100644 --- a/Makefile +++ b/Makefile @@ -2922,7 +2922,6 @@ PUBLIC_HEADERS_C += \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ - include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -2942,7 +2941,6 @@ PUBLIC_HEADERS_C += \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ - include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -4650,7 +4648,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ - include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -4670,7 +4667,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ - include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -5138,7 +5134,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ - include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -5158,7 +5153,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ - include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -5858,7 +5852,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ - include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -5878,7 +5871,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ - include/grpc/support/useful.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ diff --git a/build.yaml b/build.yaml index 32102912ba..516f270e73 100644 --- a/build.yaml +++ b/build.yaml @@ -79,7 +79,6 @@ filegroups: - include/grpc/support/atm_gcc_atomic.h - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - - include/grpc/support/avl.h - include/grpc/support/cmdline.h - include/grpc/support/cpu.h - include/grpc/support/host_port.h @@ -99,9 +98,9 @@ filegroups: - include/grpc/support/tls_gcc.h - include/grpc/support/tls_msvc.h - include/grpc/support/tls_pthread.h - - include/grpc/support/useful.h headers: - src/core/lib/gpr/arena.h + - src/core/lib/gpr/avl.h - src/core/lib/gpr/env.h - src/core/lib/gpr/fork.h - src/core/lib/gpr/mpscq.h @@ -112,6 +111,7 @@ filegroups: - src/core/lib/gpr/thd_internal.h - src/core/lib/gpr/time_precise.h - src/core/lib/gpr/tmpfile.h + - src/core/lib/gpr/useful.h - src/core/lib/gprpp/abstract.h - src/core/lib/gprpp/atomic.h - src/core/lib/gprpp/atomic_with_atm.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 45cee35335..173be45d4f 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -203,6 +203,7 @@ Pod::Spec.new do |s| 'src/cpp/util/time_cc.cc', 'src/cpp/codegen/codegen_init.cc', 'src/core/lib/gpr/arena.h', + 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -213,6 +214,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', 'src/core/lib/gpr/tmpfile.h', + 'src/core/lib/gpr/useful.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic_with_atm.h', @@ -449,6 +451,7 @@ Pod::Spec.new do |s| 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', 'src/core/lib/gpr/arena.h', + 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -459,6 +462,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', 'src/core/lib/gpr/tmpfile.h', + 'src/core/lib/gpr/useful.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic_with_atm.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b28459eb59..faba046cfd 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -114,7 +114,6 @@ Pod::Spec.new do |s| 'include/grpc/support/atm_gcc_atomic.h', 'include/grpc/support/atm_gcc_sync.h', 'include/grpc/support/atm_windows.h', - 'include/grpc/support/avl.h', 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', 'include/grpc/support/host_port.h', @@ -134,7 +133,6 @@ Pod::Spec.new do |s| 'include/grpc/support/tls_gcc.h', 'include/grpc/support/tls_msvc.h', 'include/grpc/support/tls_pthread.h', - 'include/grpc/support/useful.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', 'include/grpc/impl/codegen/atm_gcc_sync.h', @@ -194,6 +192,7 @@ Pod::Spec.new do |s| # To save you from scrolling, this is the last part of the podspec. ss.source_files = 'src/core/lib/gpr/arena.h', + 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -204,6 +203,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', 'src/core/lib/gpr/tmpfile.h', + 'src/core/lib/gpr/useful.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic_with_atm.h', @@ -721,6 +721,7 @@ Pod::Spec.new do |s| 'src/core/plugin_registry/grpc_plugin_registry.cc' ss.private_header_files = 'src/core/lib/gpr/arena.h', + 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -731,6 +732,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/thd_internal.h', 'src/core/lib/gpr/time_precise.h', 'src/core/lib/gpr/tmpfile.h', + 'src/core/lib/gpr/useful.h', 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic_with_atm.h', diff --git a/grpc.def b/grpc.def index be59ef0092..022e527247 100644 --- a/grpc.def +++ b/grpc.def @@ -178,14 +178,6 @@ EXPORTS gpr_free_aligned gpr_set_allocation_functions gpr_get_allocation_functions - gpr_avl_create - gpr_avl_ref - gpr_avl_unref - gpr_avl_add - gpr_avl_remove - gpr_avl_get - gpr_avl_maybe_get - gpr_avl_is_empty gpr_cmdline_create gpr_cmdline_add_int gpr_cmdline_add_flag diff --git a/grpc.gemspec b/grpc.gemspec index 39174cc97d..97ba668ca9 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -49,7 +49,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/atm_gcc_atomic.h ) s.files += %w( include/grpc/support/atm_gcc_sync.h ) s.files += %w( include/grpc/support/atm_windows.h ) - s.files += %w( include/grpc/support/avl.h ) s.files += %w( include/grpc/support/cmdline.h ) s.files += %w( include/grpc/support/cpu.h ) s.files += %w( include/grpc/support/host_port.h ) @@ -69,7 +68,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/tls_gcc.h ) s.files += %w( include/grpc/support/tls_msvc.h ) s.files += %w( include/grpc/support/tls_pthread.h ) - s.files += %w( include/grpc/support/useful.h ) s.files += %w( include/grpc/impl/codegen/atm.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h ) @@ -84,6 +82,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_posix.h ) s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( src/core/lib/gpr/arena.h ) + s.files += %w( src/core/lib/gpr/avl.h ) s.files += %w( src/core/lib/gpr/env.h ) s.files += %w( src/core/lib/gpr/fork.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) @@ -94,6 +93,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/thd_internal.h ) s.files += %w( src/core/lib/gpr/time_precise.h ) s.files += %w( src/core/lib/gpr/tmpfile.h ) + s.files += %w( src/core/lib/gpr/useful.h ) s.files += %w( src/core/lib/gprpp/abstract.h ) s.files += %w( src/core/lib/gprpp/atomic.h ) s.files += %w( src/core/lib/gprpp/atomic_with_atm.h ) diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index e2bae4b41f..ea9834c179 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -30,7 +30,6 @@ #include #include #include -#include #include struct grpc_resource_quota; diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index d23072f556..6c3fff030e 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -4,7 +4,6 @@ framework module grpc { header "support/alloc.h" header "support/atm.h" - header "support/avl.h" header "support/cmdline.h" header "support/cpu.h" header "support/host_port.h" @@ -18,7 +17,6 @@ framework module grpc { header "support/thd.h" header "support/time.h" header "support/tls.h" - header "support/useful.h" header "impl/codegen/atm.h" header "impl/codegen/fork.h" header "impl/codegen/gpr_slice.h" diff --git a/include/grpc/support/avl.h b/include/grpc/support/avl.h deleted file mode 100644 index b5a8c0ffa1..0000000000 --- a/include/grpc/support/avl.h +++ /dev/null @@ -1,102 +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. - * - */ - -#ifndef GRPC_SUPPORT_AVL_H -#define GRPC_SUPPORT_AVL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** internal node of an AVL tree */ -typedef struct gpr_avl_node { - gpr_refcount refs; - void* key; - void* value; - struct gpr_avl_node* left; - struct gpr_avl_node* right; - long height; -} gpr_avl_node; - -/** vtable for the AVL tree - * The optional user_data is propagated from the top level gpr_avl_XXX API. - * From the same API call, multiple vtable functions may be called multiple - * times. - */ -typedef struct gpr_avl_vtable { - /** destroy a key */ - void (*destroy_key)(void* key, void* user_data); - /** copy a key, returning new value */ - void* (*copy_key)(void* key, void* user_data); - /** compare key1, key2; return <0 if key1 < key2, - >0 if key1 > key2, 0 if key1 == key2 */ - long (*compare_keys)(void* key1, void* key2, void* user_data); - /** destroy a value */ - void (*destroy_value)(void* value, void* user_data); - /** copy a value */ - void* (*copy_value)(void* value, void* user_data); -} gpr_avl_vtable; - -/** "pointer" to an AVL tree - this is a reference - counted object - use gpr_avl_ref to add a reference, - gpr_avl_unref when done with a reference */ -typedef struct gpr_avl { - const gpr_avl_vtable* vtable; - gpr_avl_node* root; -} gpr_avl; - -/** Create an immutable AVL tree. */ -GPRAPI gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable); -/** Add a reference to an existing tree - returns - the tree as a convenience. The optional user_data will be passed to vtable - functions. */ -GPRAPI gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data); -/** Remove a reference to a tree - destroying it if there - are no references left. The optional user_data will be passed to vtable - functions. */ -GPRAPI void gpr_avl_unref(gpr_avl avl, void* user_data); -/** Return a new tree with (key, value) added to avl. - implicitly unrefs avl to allow easy chaining. - if key exists in avl, the new tree's key entry updated - (i.e. a duplicate is not created). The optional user_data will be passed to - vtable functions. */ -GPRAPI gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, - void* user_data); -/** Return a new tree with key deleted - implicitly unrefs avl to allow easy chaining. The optional user_data will be - passed to vtable functions. */ -GPRAPI gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data); -/** Lookup key, and return the associated value. - Does not mutate avl. - Returns NULL if key is not found. The optional user_data will be passed to - vtable functions.*/ -GPRAPI void* gpr_avl_get(gpr_avl avl, void* key, void* user_data); -/** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to - its value. THe optional user_data will be passed to vtable functions. */ -GPRAPI int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, - void* user_data); -/** Return 1 if avl is empty, 0 otherwise */ -GPRAPI int gpr_avl_is_empty(gpr_avl avl); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_AVL_H */ diff --git a/include/grpc/support/useful.h b/include/grpc/support/useful.h deleted file mode 100644 index bd66d3bb27..0000000000 --- a/include/grpc/support/useful.h +++ /dev/null @@ -1,65 +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. - * - */ - -#ifndef GRPC_SUPPORT_USEFUL_H -#define GRPC_SUPPORT_USEFUL_H - -/** useful macros that don't belong anywhere else */ - -#define GPR_MIN(a, b) ((a) < (b) ? (a) : (b)) -#define GPR_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define GPR_CLAMP(a, min, max) ((a) < (min) ? (min) : (a) > (max) ? (max) : (a)) -/** rotl, rotr assume x is unsigned */ -#define GPR_ROTL(x, n) (((x) << (n)) | ((x) >> (sizeof(x) * 8 - (n)))) -#define GPR_ROTR(x, n) (((x) >> (n)) | ((x) << (sizeof(x) * 8 - (n)))) - -#define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array))) - -#define GPR_SWAP(type, a, b) \ - do { \ - type x = a; \ - a = b; \ - b = x; \ - } while (0) - -/** Set the \a n-th bit of \a i (a mutable pointer). */ -#define GPR_BITSET(i, n) ((*(i)) |= (1u << (n))) - -/** Clear the \a n-th bit of \a i (a mutable pointer). */ -#define GPR_BITCLEAR(i, n) ((*(i)) &= ~(1u << (n))) - -/** Get the \a n-th bit of \a i */ -#define GPR_BITGET(i, n) (((i) & (1u << (n))) != 0) - -#define GPR_INTERNAL_HEXDIGIT_BITCOUNT(x) \ - ((x) - (((x) >> 1) & 0x77777777) - (((x) >> 2) & 0x33333333) - \ - (((x) >> 3) & 0x11111111)) - -/** Returns number of bits set in bitset \a i */ -#define GPR_BITCOUNT(i) \ - (((GPR_INTERNAL_HEXDIGIT_BITCOUNT(i) + \ - (GPR_INTERNAL_HEXDIGIT_BITCOUNT(i) >> 4)) & \ - 0x0f0f0f0f) % \ - 255) - -#define GPR_ICMP(a, b) ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0)) - -#define GPR_HASH_POINTER(x, range) \ - ((((size_t)x) >> 4) ^ (((size_t)x) >> 9) ^ (((size_t)x) >> 14)) % (range) - -#endif /* GRPC_SUPPORT_USEFUL_H */ diff --git a/package.xml b/package.xml index 7c32a73b4f..438856cd69 100644 --- a/package.xml +++ b/package.xml @@ -56,7 +56,6 @@ - @@ -76,7 +75,6 @@ - @@ -91,6 +89,7 @@ + @@ -101,6 +100,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 49522ef3e4..bca4ecbc25 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc index e19a6a71aa..45c9f17301 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.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 2eb2a9b59d..2bf86f82b0 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 @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/ev_posix.h" 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 e05f9d2f2f..09dbe22a86 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 @@ -32,7 +32,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" diff --git a/src/core/ext/filters/client_channel/retry_throttle.cc b/src/core/ext/filters/client_channel/retry_throttle.cc index 867d775151..20d7be1c21 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.cc +++ b/src/core/ext/filters/client_channel/retry_throttle.cc @@ -23,10 +23,11 @@ #include #include -#include #include #include +#include "src/core/lib/gpr/avl.h" + // // server_retry_throttle_data // diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index dc1beee165..3d4771e9bf 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -25,7 +25,6 @@ #include #include -#include #include #include "src/core/ext/filters/client_channel/client_channel.h" diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc index 052b047f43..2d063973ca 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.cc +++ b/src/core/ext/filters/client_channel/subchannel_index.cc @@ -22,11 +22,11 @@ #include #include -#include #include #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/avl.h" // a map of subchannel_key --> subchannel, used for detecting connections // to the same destination in order to share them diff --git a/src/core/ext/transport/chttp2/alpn/alpn.cc b/src/core/ext/transport/chttp2/alpn/alpn.cc index 89892457d6..5c4bfd03fa 100644 --- a/src/core/ext/transport/chttp2/alpn/alpn.cc +++ b/src/core/ext/transport/chttp2/alpn/alpn.cc @@ -18,7 +18,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include -#include + +#include "src/core/lib/gpr/useful.h" /* in order of preference */ static const char* const supported_versions[] = {"grpc-exp", "h2"}; diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 5669fa4090..bab46f8f30 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index fe05e43960..bc1762daad 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -30,7 +30,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/frame_data.h" #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index 581241d392..311fbd60b1 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h index 2ee1345260..19c189393f 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/src/core/ext/transport/chttp2/transport/flow_control.h @@ -22,8 +22,8 @@ #include #include -#include #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/transport/bdp_estimator.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 043b80a3cb..5ea495f2db 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index 0d245f4ba1..36d6b48f02 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/frame.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 3a5692a694..ba6b43b1dd 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -28,7 +28,6 @@ #include #include -#include #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_table.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 8d1c57a9cb..66cc2884e1 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/lib/debug/stats.h" diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.cc b/src/core/ext/transport/chttp2/transport/http2_settings.cc index 0aab864400..4248496f48 100644 --- a/src/core/ext/transport/chttp2/transport/http2_settings.cc +++ b/src/core/ext/transport/chttp2/transport/http2_settings.cc @@ -20,7 +20,7 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/transport/http2_errors.h" const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027}; diff --git a/src/core/ext/transport/chttp2/transport/stream_map.cc b/src/core/ext/transport/chttp2/transport/stream_map.cc index e4f08f5a6c..d59ff405f5 100644 --- a/src/core/ext/transport/chttp2/transport/stream_map.cc +++ b/src/core/ext/transport/chttp2/transport/stream_map.cc @@ -22,7 +22,6 @@ #include #include -#include void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map, size_t initial_capacity) { diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 5b1c6ab3f9..7735c3de6e 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" diff --git a/src/core/lib/backoff/backoff.cc b/src/core/lib/backoff/backoff.cc index d561fc7460..9275fc2894 100644 --- a/src/core/lib/backoff/backoff.cc +++ b/src/core/lib/backoff/backoff.cc @@ -20,7 +20,7 @@ #include -#include +#include "src/core/lib/gpr/useful.h" namespace grpc_core { diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index 101a6fffbc..5cd158aff2 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -26,10 +26,10 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" static grpc_arg copy_arg(const grpc_arg* src) { grpc_arg dst; diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc index 99e6014b23..be7febf380 100644 --- a/src/core/lib/compression/compression.cc +++ b/src/core/lib/compression/compression.cc @@ -20,10 +20,10 @@ #include #include -#include #include "src/core/lib/compression/algorithm_metadata.h" #include "src/core/lib/compression/compression_internal.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index 263cdf06eb..0583705dc1 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -20,10 +20,10 @@ #include #include -#include #include "src/core/lib/compression/algorithm_metadata.h" #include "src/core/lib/compression/compression_internal.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/src/core/lib/compression/compression_ruby.cc b/src/core/lib/compression/compression_ruby.cc index 293062f5ed..4e2d01aab1 100644 --- a/src/core/lib/compression/compression_ruby.cc +++ b/src/core/lib/compression/compression_ruby.cc @@ -17,7 +17,6 @@ */ #include -#include #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/src/core/lib/debug/stats.cc b/src/core/lib/debug/stats.cc index 465c76114d..40355c2d45 100644 --- a/src/core/lib/debug/stats.cc +++ b/src/core/lib/debug/stats.cc @@ -23,9 +23,9 @@ #include #include -#include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" grpc_stats_data* grpc_stats_per_cpu_storage = nullptr; static size_t g_num_cores; diff --git a/src/core/lib/debug/stats_data.cc b/src/core/lib/debug/stats_data.cc index 996ed3de9a..e2d3a6d073 100644 --- a/src/core/lib/debug/stats_data.cc +++ b/src/core/lib/debug/stats_data.cc @@ -19,9 +19,10 @@ */ #include "src/core/lib/debug/stats_data.h" -#include #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" + const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = { "client_calls_created", "server_calls_created", diff --git a/src/core/lib/gpr/arena.cc b/src/core/lib/gpr/arena.cc index 687592a140..5a8d7ff6ec 100644 --- a/src/core/lib/gpr/arena.cc +++ b/src/core/lib/gpr/arena.cc @@ -23,7 +23,6 @@ #include #include #include -#include // TODO(roth): We currently assume that all callers need alignment of 16 // bytes, which may be wrong in some cases. As part of converting the diff --git a/src/core/lib/gpr/atm.cc b/src/core/lib/gpr/atm.cc index 15bfe52d64..3d0b430348 100644 --- a/src/core/lib/gpr/atm.cc +++ b/src/core/lib/gpr/atm.cc @@ -17,7 +17,8 @@ */ #include -#include + +#include "src/core/lib/gpr/useful.h" gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta, gpr_atm min, gpr_atm max) { diff --git a/src/core/lib/gpr/avl.cc b/src/core/lib/gpr/avl.cc index 0b67a21f2f..9d3470fe0a 100644 --- a/src/core/lib/gpr/avl.cc +++ b/src/core/lib/gpr/avl.cc @@ -16,14 +16,15 @@ * */ -#include +#include "src/core/lib/gpr/avl.h" #include #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) { gpr_avl out; diff --git a/src/core/lib/gpr/avl.h b/src/core/lib/gpr/avl.h new file mode 100644 index 0000000000..f3ab202bb7 --- /dev/null +++ b/src/core/lib/gpr/avl.h @@ -0,0 +1,92 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_AVL_H +#define GRPC_CORE_LIB_GPR_AVL_H + +#include + +/** internal node of an AVL tree */ +typedef struct gpr_avl_node { + gpr_refcount refs; + void* key; + void* value; + struct gpr_avl_node* left; + struct gpr_avl_node* right; + long height; +} gpr_avl_node; + +/** vtable for the AVL tree + * The optional user_data is propagated from the top level gpr_avl_XXX API. + * From the same API call, multiple vtable functions may be called multiple + * times. + */ +typedef struct gpr_avl_vtable { + /** destroy a key */ + void (*destroy_key)(void* key, void* user_data); + /** copy a key, returning new value */ + void* (*copy_key)(void* key, void* user_data); + /** compare key1, key2; return <0 if key1 < key2, + >0 if key1 > key2, 0 if key1 == key2 */ + long (*compare_keys)(void* key1, void* key2, void* user_data); + /** destroy a value */ + void (*destroy_value)(void* value, void* user_data); + /** copy a value */ + void* (*copy_value)(void* value, void* user_data); +} gpr_avl_vtable; + +/** "pointer" to an AVL tree - this is a reference + counted object - use gpr_avl_ref to add a reference, + gpr_avl_unref when done with a reference */ +typedef struct gpr_avl { + const gpr_avl_vtable* vtable; + gpr_avl_node* root; +} gpr_avl; + +/** Create an immutable AVL tree. */ +gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable); +/** Add a reference to an existing tree - returns + the tree as a convenience. The optional user_data will be passed to vtable + functions. */ +gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data); +/** Remove a reference to a tree - destroying it if there + are no references left. The optional user_data will be passed to vtable + functions. */ +void gpr_avl_unref(gpr_avl avl, void* user_data); +/** Return a new tree with (key, value) added to avl. + implicitly unrefs avl to allow easy chaining. + if key exists in avl, the new tree's key entry updated + (i.e. a duplicate is not created). The optional user_data will be passed to + vtable functions. */ +gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data); +/** Return a new tree with key deleted + implicitly unrefs avl to allow easy chaining. The optional user_data will be + passed to vtable functions. */ +gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data); +/** Lookup key, and return the associated value. + Does not mutate avl. + Returns NULL if key is not found. The optional user_data will be passed to + vtable functions.*/ +void* gpr_avl_get(gpr_avl avl, void* key, void* user_data); +/** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to + its value. The optional user_data will be passed to vtable functions. */ +int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data); +/** Return 1 if avl is empty, 0 otherwise */ +int gpr_avl_is_empty(gpr_avl avl); + +#endif /* GRPC_CORE_LIB_GPR_AVL_H */ diff --git a/src/core/lib/gpr/cpu_posix.cc b/src/core/lib/gpr/cpu_posix.cc index bca14a0c12..7a77f7ab64 100644 --- a/src/core/lib/gpr/cpu_posix.cc +++ b/src/core/lib/gpr/cpu_posix.cc @@ -29,7 +29,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" static long ncpus = 0; diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index 17902c3d0b..fadc42f22f 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -34,9 +34,9 @@ #include #include -#include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" const char* gpr_getenv_silent(const char* name, char** dst) { const char* insecure_func_used = nullptr; diff --git a/src/core/lib/gpr/env_windows.cc b/src/core/lib/gpr/env_windows.cc index 9ca1e02d03..cf8ed60d8f 100644 --- a/src/core/lib/gpr/env_windows.cc +++ b/src/core/lib/gpr/env_windows.cc @@ -22,14 +22,14 @@ #include -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/string_windows.h" - #include #include #include +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/string_windows.h" + const char* gpr_getenv_silent(const char* name, char** dst) { *dst = gpr_getenv(name); return NULL; diff --git a/src/core/lib/gpr/fork.cc b/src/core/lib/gpr/fork.cc index 92023f4350..4651d22595 100644 --- a/src/core/lib/gpr/fork.cc +++ b/src/core/lib/gpr/fork.cc @@ -21,9 +21,9 @@ #include #include -#include #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/useful.h" /* * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index 919d957d1b..6b360e4013 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -28,7 +28,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" char* gpr_strdup(const char* src) { char* dst; diff --git a/src/core/lib/gpr/thd_posix.cc b/src/core/lib/gpr/thd_posix.cc index cfff0df6de..683fd4575e 100644 --- a/src/core/lib/gpr/thd_posix.cc +++ b/src/core/lib/gpr/thd_posix.cc @@ -26,12 +26,12 @@ #include #include #include -#include #include #include #include #include "src/core/lib/gpr/fork.h" +#include "src/core/lib/gpr/useful.h" static gpr_mu g_mu; static gpr_cv g_cv; diff --git a/src/core/lib/gpr/useful.h b/src/core/lib/gpr/useful.h new file mode 100644 index 0000000000..a4e73b9a61 --- /dev/null +++ b/src/core/lib/gpr/useful.h @@ -0,0 +1,65 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GPR_USEFUL_H +#define GRPC_CORE_LIB_GPR_USEFUL_H + +/** useful macros that don't belong anywhere else */ + +#define GPR_MIN(a, b) ((a) < (b) ? (a) : (b)) +#define GPR_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define GPR_CLAMP(a, min, max) ((a) < (min) ? (min) : (a) > (max) ? (max) : (a)) +/** rotl, rotr assume x is unsigned */ +#define GPR_ROTL(x, n) (((x) << (n)) | ((x) >> (sizeof(x) * 8 - (n)))) +#define GPR_ROTR(x, n) (((x) >> (n)) | ((x) << (sizeof(x) * 8 - (n)))) + +#define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array))) + +#define GPR_SWAP(type, a, b) \ + do { \ + type x = a; \ + a = b; \ + b = x; \ + } while (0) + +/** Set the \a n-th bit of \a i (a mutable pointer). */ +#define GPR_BITSET(i, n) ((*(i)) |= (1u << (n))) + +/** Clear the \a n-th bit of \a i (a mutable pointer). */ +#define GPR_BITCLEAR(i, n) ((*(i)) &= ~(1u << (n))) + +/** Get the \a n-th bit of \a i */ +#define GPR_BITGET(i, n) (((i) & (1u << (n))) != 0) + +#define GPR_INTERNAL_HEXDIGIT_BITCOUNT(x) \ + ((x) - (((x) >> 1) & 0x77777777) - (((x) >> 2) & 0x33333333) - \ + (((x) >> 3) & 0x11111111)) + +/** Returns number of bits set in bitset \a i */ +#define GPR_BITCOUNT(i) \ + (((GPR_INTERNAL_HEXDIGIT_BITCOUNT(i) + \ + (GPR_INTERNAL_HEXDIGIT_BITCOUNT(i) >> 4)) & \ + 0x0f0f0f0f) % \ + 255) + +#define GPR_ICMP(a, b) ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0)) + +#define GPR_HASH_POINTER(x, range) \ + ((((size_t)x) >> 4) ^ (((size_t)x) >> 9) ^ (((size_t)x) >> 14)) % (range) + +#endif /* GRPC_CORE_LIB_GPR_USEFUL_H */ diff --git a/src/core/lib/http/format_request.cc b/src/core/lib/http/format_request.cc index 473fa71790..884a70e550 100644 --- a/src/core/lib/http/format_request.cc +++ b/src/core/lib/http/format_request.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" static void fill_common_header(const grpc_httpcli_request* request, diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc index c43c92b57d..9775ed08ad 100644 --- a/src/core/lib/http/httpcli.cc +++ b/src/core/lib/http/httpcli.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/lib/http/parser.cc b/src/core/lib/http/parser.cc index fb4eb234a7..ee6941fde3 100644 --- a/src/core/lib/http/parser.cc +++ b/src/core/lib/http/parser.cc @@ -23,7 +23,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" grpc_core::TraceFlag grpc_http1_trace(false, "http1"); diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index 0e27ad427c..d5b5013269 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -26,13 +26,13 @@ #include #include #include -#include #ifdef GPR_WINDOWS #include #endif #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/error_internal.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 1ef70d2f80..512905d683 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -40,10 +40,10 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 178ebd8977..aaace58dd5 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -38,10 +38,10 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index c8954894ec..b174615c83 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -40,9 +40,9 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index ad92a93beb..84be1804a2 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -35,10 +35,10 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/wakeup_fd_cv.h" diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 8100bece8f..af5dfe5bf3 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -27,10 +27,10 @@ #include #include #include -#include #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include "src/core/lib/iomgr/ev_epollex_linux.h" #include "src/core/lib/iomgr/ev_epollsig_linux.h" diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 835dc9d0f7..ca67c043c1 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -26,10 +26,10 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #define MAX_DEPTH 2 diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 9bfa79219a..c581dae1ae 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/fork.h" diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc index 0b6e6823b3..d730ce4624 100644 --- a/src/core/lib/iomgr/iocp_windows.cc +++ b/src/core/lib/iomgr/iocp_windows.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index 4cd0a4f1de..9e407a29a8 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -29,10 +29,10 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index 176caee490..131a8de30a 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -32,8 +32,9 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" diff --git a/src/core/lib/iomgr/resolve_address_uv.cc b/src/core/lib/iomgr/resolve_address_uv.cc index 3eab04f3de..886c06cdb7 100644 --- a/src/core/lib/iomgr/resolve_address_uv.cc +++ b/src/core/lib/iomgr/resolve_address_uv.cc @@ -25,8 +25,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index eaf2f5d1b2..e64d772a7d 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -27,8 +27,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/combiner.h" grpc_core::TraceFlag grpc_resource_quota_trace(false, "resource_quota"); diff --git a/src/core/lib/iomgr/socket_factory_posix.cc b/src/core/lib/iomgr/socket_factory_posix.cc index bc7d0b12f3..1c1b2fb270 100644 --- a/src/core/lib/iomgr/socket_factory_posix.cc +++ b/src/core/lib/iomgr/socket_factory_posix.cc @@ -21,11 +21,11 @@ #ifdef GRPC_POSIX_SOCKET #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/socket_factory_posix.h" #include #include -#include void grpc_socket_factory_init(grpc_socket_factory* factory, const grpc_socket_factory_vtable* vtable) { diff --git a/src/core/lib/iomgr/socket_mutator.cc b/src/core/lib/iomgr/socket_mutator.cc index 9d30e46b6b..8c8f0e56e1 100644 --- a/src/core/lib/iomgr/socket_mutator.cc +++ b/src/core/lib/iomgr/socket_mutator.cc @@ -18,11 +18,11 @@ #include "src/core/lib/iomgr/socket_mutator.h" -#include "src/core/lib/channel/channel_args.h" - #include #include -#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" void grpc_socket_mutator_init(grpc_socket_mutator* mutator, const grpc_socket_mutator_vtable* vtable) { diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc index 97aa9237dc..d46569d7cc 100644 --- a/src/core/lib/iomgr/tcp_client_windows.cc +++ b/src/core/lib/iomgr/tcp_client_windows.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 07aed2d1fd..e78e19761a 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -37,12 +37,12 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/profiling/timers.h" diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 2fa00a81d2..89d9160e02 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -42,7 +42,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc index 6d091b77bb..6777719785 100644 --- a/src/core/lib/iomgr/tcp_windows.cc +++ b/src/core/lib/iomgr/tcp_windows.cc @@ -30,8 +30,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iocp_windows.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 177bdec8df..5d0fcdea4f 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -30,9 +30,10 @@ #include #include #include -#include + #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/spinlock.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/time_averaged_stats.h" #include "src/core/lib/iomgr/timer_heap.h" diff --git a/src/core/lib/iomgr/timer_heap.cc b/src/core/lib/iomgr/timer_heap.cc index b350452c63..632928fafa 100644 --- a/src/core/lib/iomgr/timer_heap.cc +++ b/src/core/lib/iomgr/timer_heap.cc @@ -25,7 +25,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" /* Adjusts a heap so as to move a hole at position i closer to the root, until a suitable position is found for element t. Then, copies t into that diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc index af862c00dc..91b7cb1e59 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/src/core/lib/iomgr/unix_sockets_posix.cc @@ -30,7 +30,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" void grpc_create_socketpair_if_unix(int sv[2]) { GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0); diff --git a/src/core/lib/iomgr/wakeup_fd_cv.cc b/src/core/lib/iomgr/wakeup_fd_cv.cc index c785114212..4818cafe3d 100644 --- a/src/core/lib/iomgr/wakeup_fd_cv.cc +++ b/src/core/lib/iomgr/wakeup_fd_cv.cc @@ -30,7 +30,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #define MAX_TABLE_RESIZE 256 diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc index 860506df39..8b22307944 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc @@ -25,7 +25,6 @@ #include #include #include -#include extern "C" { #include diff --git a/src/core/lib/slice/b64.cc b/src/core/lib/slice/b64.cc index f36b13ef1b..5c6610c372 100644 --- a/src/core/lib/slice/b64.cc +++ b/src/core/lib/slice/b64.cc @@ -23,8 +23,8 @@ #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" /* --- Constants. --- */ diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 33ec2af683..178c7f9e94 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -23,8 +23,8 @@ #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" /* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index f2096d8937..a77dc70ba0 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -28,13 +28,13 @@ #include #include #include -#include #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/compression/algorithm_metadata.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/arena.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/lib/surface/channel_init.cc b/src/core/lib/surface/channel_init.cc index 95cbbbd037..99690e63b4 100644 --- a/src/core/lib/surface/channel_init.cc +++ b/src/core/lib/surface/channel_init.cc @@ -19,7 +19,6 @@ #include "src/core/lib/surface/channel_init.h" #include -#include typedef struct stage_slot { grpc_channel_init_stage fn; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index c8c1db337f..1e59434aa5 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index 5fcc62ec43..2ba1cfdaa6 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -21,7 +21,7 @@ #include #include -#include +#include "src/core/lib/gpr/useful.h" grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator"); diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 78e6beff9b..82142ebed8 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -21,8 +21,8 @@ #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; diff --git a/src/core/lib/transport/pid_controller.cc b/src/core/lib/transport/pid_controller.cc index e31cc85f76..b33ea63df6 100644 --- a/src/core/lib/transport/pid_controller.cc +++ b/src/core/lib/transport/pid_controller.cc @@ -17,7 +17,8 @@ */ #include "src/core/lib/transport/pid_controller.h" -#include + +#include "src/core/lib/gpr/useful.h" namespace grpc_core { diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index 58a21e9b60..6898da17ed 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -27,7 +27,6 @@ #include #include -#include #include "src/core/lib/gpr/string.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/transport/connectivity_state.h" diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc index b907636f9d..7d5aaa7305 100644 --- a/src/core/tsi/fake_transport_security.cc +++ b/src/core/tsi/fake_transport_security.cc @@ -24,7 +24,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/transport_security_grpc.h" diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index b396a621bd..6de02d4952 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -37,7 +37,6 @@ #include #include #include -#include extern "C" { #include diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index 362dff642c..e4ed3490fd 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/profiling/timers.h" diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 200e477822..790095e1f6 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -23,8 +23,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/cpp/server/thread_pool_interface.h" namespace grpc { diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 0734fb31d5..81221acc08 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -201,14 +201,6 @@ gpr_malloc_aligned_type gpr_malloc_aligned_import; gpr_free_aligned_type gpr_free_aligned_import; gpr_set_allocation_functions_type gpr_set_allocation_functions_import; gpr_get_allocation_functions_type gpr_get_allocation_functions_import; -gpr_avl_create_type gpr_avl_create_import; -gpr_avl_ref_type gpr_avl_ref_import; -gpr_avl_unref_type gpr_avl_unref_import; -gpr_avl_add_type gpr_avl_add_import; -gpr_avl_remove_type gpr_avl_remove_import; -gpr_avl_get_type gpr_avl_get_import; -gpr_avl_maybe_get_type gpr_avl_maybe_get_import; -gpr_avl_is_empty_type gpr_avl_is_empty_import; gpr_cmdline_create_type gpr_cmdline_create_import; gpr_cmdline_add_int_type gpr_cmdline_add_int_import; gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; @@ -470,14 +462,6 @@ void grpc_rb_load_imports(HMODULE library) { gpr_free_aligned_import = (gpr_free_aligned_type) GetProcAddress(library, "gpr_free_aligned"); gpr_set_allocation_functions_import = (gpr_set_allocation_functions_type) GetProcAddress(library, "gpr_set_allocation_functions"); gpr_get_allocation_functions_import = (gpr_get_allocation_functions_type) GetProcAddress(library, "gpr_get_allocation_functions"); - gpr_avl_create_import = (gpr_avl_create_type) GetProcAddress(library, "gpr_avl_create"); - gpr_avl_ref_import = (gpr_avl_ref_type) GetProcAddress(library, "gpr_avl_ref"); - gpr_avl_unref_import = (gpr_avl_unref_type) GetProcAddress(library, "gpr_avl_unref"); - gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add"); - gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove"); - gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get"); - gpr_avl_maybe_get_import = (gpr_avl_maybe_get_type) GetProcAddress(library, "gpr_avl_maybe_get"); - gpr_avl_is_empty_import = (gpr_avl_is_empty_type) GetProcAddress(library, "gpr_avl_is_empty"); gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create"); gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int"); gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 9e5dd2d699..5f2b754d15 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -583,30 +582,6 @@ extern gpr_set_allocation_functions_type gpr_set_allocation_functions_import; typedef gpr_allocation_functions(*gpr_get_allocation_functions_type)(void); extern gpr_get_allocation_functions_type gpr_get_allocation_functions_import; #define gpr_get_allocation_functions gpr_get_allocation_functions_import -typedef gpr_avl(*gpr_avl_create_type)(const gpr_avl_vtable* vtable); -extern gpr_avl_create_type gpr_avl_create_import; -#define gpr_avl_create gpr_avl_create_import -typedef gpr_avl(*gpr_avl_ref_type)(gpr_avl avl, void* user_data); -extern gpr_avl_ref_type gpr_avl_ref_import; -#define gpr_avl_ref gpr_avl_ref_import -typedef void(*gpr_avl_unref_type)(gpr_avl avl, void* user_data); -extern gpr_avl_unref_type gpr_avl_unref_import; -#define gpr_avl_unref gpr_avl_unref_import -typedef gpr_avl(*gpr_avl_add_type)(gpr_avl avl, void* key, void* value, void* user_data); -extern gpr_avl_add_type gpr_avl_add_import; -#define gpr_avl_add gpr_avl_add_import -typedef gpr_avl(*gpr_avl_remove_type)(gpr_avl avl, void* key, void* user_data); -extern gpr_avl_remove_type gpr_avl_remove_import; -#define gpr_avl_remove gpr_avl_remove_import -typedef void*(*gpr_avl_get_type)(gpr_avl avl, void* key, void* user_data); -extern gpr_avl_get_type gpr_avl_get_import; -#define gpr_avl_get gpr_avl_get_import -typedef int(*gpr_avl_maybe_get_type)(gpr_avl avl, void* key, void** value, void* user_data); -extern gpr_avl_maybe_get_type gpr_avl_maybe_get_import; -#define gpr_avl_maybe_get gpr_avl_maybe_get_import -typedef int(*gpr_avl_is_empty_type)(gpr_avl avl); -extern gpr_avl_is_empty_type gpr_avl_is_empty_import; -#define gpr_avl_is_empty gpr_avl_is_empty_import typedef gpr_cmdline*(*gpr_cmdline_create_type)(const char* description); extern gpr_cmdline_create_type gpr_cmdline_create_import; #define gpr_cmdline_create gpr_cmdline_create_import diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc index 2e61243831..53e910eddd 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include "test/core/util/test_config.h" diff --git a/test/core/bad_ssl/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc index 23954d82fd..4a04178b1c 100644 --- a/test/core/bad_ssl/servers/alpn.cc +++ b/test/core/bad_ssl/servers/alpn.cc @@ -21,9 +21,9 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/alpn/alpn.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/bad_ssl/server_common.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc index a51dd34e4b..3ed7d029ee 100644 --- a/test/core/bad_ssl/servers/cert.cc +++ b/test/core/bad_ssl/servers/cert.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include "src/core/lib/iomgr/load_file.h" diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc index 5b0a770c84..3a4844881d 100644 --- a/test/core/channel/channel_args_test.cc +++ b/test/core/channel/channel_args_test.cc @@ -19,9 +19,9 @@ #include #include -#include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 1699d27142..632077dd17 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -23,7 +23,6 @@ #include #include -#include #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc index e49a93a4b6..c60aa6f38e 100644 --- a/test/core/compression/compression_test.cc +++ b/test/core/compression/compression_test.cc @@ -22,8 +22,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_compression_algorithm_parse(void) { diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc index bab32e0cc5..e3fe825fdf 100644 --- a/test/core/compression/message_compress_test.cc +++ b/test/core/compression/message_compress_test.cc @@ -23,9 +23,9 @@ #include #include -#include #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc index 7bf8ae0f6e..a7b37f3c12 100644 --- a/test/core/end2end/cq_verifier.cc +++ b/test/core/end2end/cq_verifier.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/event_string.h" diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 75c80aa1ff..49e0d4e13b 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 3625afefcd..c6a9bfa803 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index b080591e85..4a846c0151 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -30,7 +30,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 7104fbc581..38edc2696b 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -30,7 +30,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index 237841d185..75c653917e 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -25,7 +25,7 @@ #include #include #include -#include + #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index 6d15c28662..6f2a37cf22 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -25,7 +25,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index e8e81f0930..38d1a82dda 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc index fda5f4b052..44a73f9fd1 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.cc +++ b/test/core/end2end/fixtures/h2_load_reporting.cc @@ -25,7 +25,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index 295654cb6a..60fa47d46d 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -25,7 +25,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 236780b8d3..92b9a463c1 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -29,7 +29,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index b68279fd71..46acf1f615 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -24,7 +24,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index 350be138ca..6499c90271 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -24,7 +24,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index 1944dd84a3..c5869cf457 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -28,7 +28,7 @@ #include #include #include -#include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 8ec97df3e4..5bff1f1e6f 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -31,7 +31,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index b748fbf09a..2ef8139425 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index b1698c804c..d77dc2ca6b 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -25,8 +25,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { diff --git a/test/core/end2end/tests/authority_not_supported.cc b/test/core/end2end/tests/authority_not_supported.cc index 9c8545058c..f2852f772e 100644 --- a/test/core/end2end/tests/authority_not_supported.cc +++ b/test/core/end2end/tests/authority_not_supported.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/bad_hostname.cc b/test/core/end2end/tests/bad_hostname.cc index 85e9ba1307..63bfd76120 100644 --- a/test/core/end2end/tests/bad_hostname.cc +++ b/test/core/end2end/tests/bad_hostname.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/bad_ping.cc b/test/core/end2end/tests/bad_ping.cc index 30a1b8de77..672c2f4c6e 100644 --- a/test/core/end2end/tests/bad_ping.cc +++ b/test/core/end2end/tests/bad_ping.cc @@ -25,8 +25,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_PING_STRIKES 1 diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc index 381671e331..8a0d667428 100644 --- a/test/core/end2end/tests/binary_metadata.cc +++ b/test/core/end2end/tests/binary_metadata.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc index c5ea101c53..968dab1995 100644 --- a/test/core/end2end/tests/call_creds.cc +++ b/test/core/end2end/tests/call_creds.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index f59caf7e35..11bf4e79b7 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/cancel_after_client_done.cc b/test/core/end2end/tests/cancel_after_client_done.cc index 9b832d435d..b0702b7f44 100644 --- a/test/core/end2end/tests/cancel_after_client_done.cc +++ b/test/core/end2end/tests/cancel_after_client_done.cc @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_after_invoke.cc b/test/core/end2end/tests/cancel_after_invoke.cc index d3891b160e..a3e36e0e3f 100644 --- a/test/core/end2end/tests/cancel_after_invoke.cc +++ b/test/core/end2end/tests/cancel_after_invoke.cc @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index b10b93978d..63e6505f0e 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/cancel_before_invoke.cc b/test/core/end2end/tests/cancel_before_invoke.cc index 1112375176..e9fa0466fb 100644 --- a/test/core/end2end/tests/cancel_before_invoke.cc +++ b/test/core/end2end/tests/cancel_before_invoke.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.cc b/test/core/end2end/tests/cancel_in_a_vacuum.cc index a6c534eb08..6be2d69095 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.cc +++ b/test/core/end2end/tests/cancel_in_a_vacuum.cc @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_with_status.cc b/test/core/end2end/tests/cancel_with_status.cc index 7937fd161f..6820ba5a2f 100644 --- a/test/core/end2end/tests/cancel_with_status.cc +++ b/test/core/end2end/tests/cancel_with_status.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index c08653b1c8..39491d8196 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc index 7c94420540..33be5f1273 100644 --- a/test/core/end2end/tests/default_host.cc +++ b/test/core/end2end/tests/default_host.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/disappearing_server.cc b/test/core/end2end/tests/disappearing_server.cc index 29fb19463f..1b2f729ba8 100644 --- a/test/core/end2end/tests/disappearing_server.cc +++ b/test/core/end2end/tests/disappearing_server.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/empty_batch.cc b/test/core/end2end/tests/empty_batch.cc index c41e65ddd2..1de4b8fda8 100644 --- a/test/core/end2end/tests/empty_batch.cc +++ b/test/core/end2end/tests/empty_batch.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc index 8f46f0bb91..f60a47f8ff 100644 --- a/test/core/end2end/tests/filter_call_init_fails.cc +++ b/test/core/end2end/tests/filter_call_init_fails.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc index ec8f9dbe00..43f20d7cc0 100644 --- a/test/core/end2end/tests/filter_causes_close.cc +++ b/test/core/end2end/tests/filter_causes_close.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc index 845cbc01cf..d6cf3b034e 100644 --- a/test/core/end2end/tests/filter_latency.cc +++ b/test/core/end2end/tests/filter_latency.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc index 61c658b95a..ad80f23d6f 100644 --- a/test/core/end2end/tests/filter_status_code.cc +++ b/test/core/end2end/tests/filter_status_code.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/graceful_server_shutdown.cc b/test/core/end2end/tests/graceful_server_shutdown.cc index bf11b49fa4..3b6872bfd7 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.cc +++ b/test/core/end2end/tests/graceful_server_shutdown.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc index d4d4f5a817..989cd5610f 100644 --- a/test/core/end2end/tests/high_initial_seqno.cc +++ b/test/core/end2end/tests/high_initial_seqno.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc index 0d6ec01e36..66b3a4019f 100644 --- a/test/core/end2end/tests/hpack_size.cc +++ b/test/core/end2end/tests/hpack_size.cc @@ -27,9 +27,9 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/idempotent_request.cc b/test/core/end2end/tests/idempotent_request.cc index 7487e4d83d..578510d407 100644 --- a/test/core/end2end/tests/idempotent_request.cc +++ b/test/core/end2end/tests/idempotent_request.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/invoke_large_request.cc b/test/core/end2end/tests/invoke_large_request.cc index 8a67e3c2b1..b7afa97401 100644 --- a/test/core/end2end/tests/invoke_large_request.cc +++ b/test/core/end2end/tests/invoke_large_request.cc @@ -26,7 +26,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 6482b86825..0cdd12e9ca 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -25,10 +25,11 @@ #include #include #include -#include + #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc index 8ddf433ac0..c1343f902d 100644 --- a/test/core/end2end/tests/large_metadata.cc +++ b/test/core/end2end/tests/large_metadata.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc index e056bd547b..cfe5814755 100644 --- a/test/core/end2end/tests/load_reporting_hook.cc +++ b/test/core/end2end/tests/load_reporting_hook.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc index c0539739e1..642c0f7ce6 100644 --- a/test/core/end2end/tests/max_concurrent_streams.cc +++ b/test/core/end2end/tests/max_concurrent_streams.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index ddccfc3b51..df5fd5cc1e 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -24,8 +24,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_CONNECTION_AGE_MS 500 diff --git a/test/core/end2end/tests/max_connection_idle.cc b/test/core/end2end/tests/max_connection_idle.cc index 293ff7d1f2..09b4a54df3 100644 --- a/test/core/end2end/tests/max_connection_idle.cc +++ b/test/core/end2end/tests/max_connection_idle.cc @@ -25,8 +25,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_CONNECTION_IDLE_MS 500 diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index e581f1fc20..b1757a9b0d 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/negative_deadline.cc b/test/core/end2end/tests/negative_deadline.cc index b752bf9482..b28bee0fb2 100644 --- a/test/core/end2end/tests/negative_deadline.cc +++ b/test/core/end2end/tests/negative_deadline.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/network_status_change.cc b/test/core/end2end/tests/network_status_change.cc index 7d0318fda6..809f8ffb5c 100644 --- a/test/core/end2end/tests/network_status_change.cc +++ b/test/core/end2end/tests/network_status_change.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" /* this is a private API but exposed here for testing*/ diff --git a/test/core/end2end/tests/no_logging.cc b/test/core/end2end/tests/no_logging.cc index d89918bd3e..b4908d4926 100644 --- a/test/core/end2end/tests/no_logging.cc +++ b/test/core/end2end/tests/no_logging.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/no_op.cc b/test/core/end2end/tests/no_op.cc index 18c2367ac4..020f842219 100644 --- a/test/core/end2end/tests/no_op.cc +++ b/test/core/end2end/tests/no_op.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/payload.cc b/test/core/end2end/tests/payload.cc index 2e9513b9cb..3535d802e9 100644 --- a/test/core/end2end/tests/payload.cc +++ b/test/core/end2end/tests/payload.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/ping.cc b/test/core/end2end/tests/ping.cc index 725a425fbf..c01dfa858f 100644 --- a/test/core/end2end/tests/ping.cc +++ b/test/core/end2end/tests/ping.cc @@ -22,8 +22,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define PING_NUM 5 diff --git a/test/core/end2end/tests/ping_pong_streaming.cc b/test/core/end2end/tests/ping_pong_streaming.cc index ec7981fdcb..714a7681b2 100644 --- a/test/core/end2end/tests/ping_pong_streaming.cc +++ b/test/core/end2end/tests/ping_pong_streaming.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/proxy_auth.cc b/test/core/end2end/tests/proxy_auth.cc index 495151b592..c34505c878 100644 --- a/test/core/end2end/tests/proxy_auth.cc +++ b/test/core/end2end/tests/proxy_auth.cc @@ -31,7 +31,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/registered_call.cc b/test/core/end2end/tests/registered_call.cc index cefa89db4d..d1c37dca20 100644 --- a/test/core/end2end/tests/registered_call.cc +++ b/test/core/end2end/tests/registered_call.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/request_with_flags.cc b/test/core/end2end/tests/request_with_flags.cc index 984d8b10f1..46023133ba 100644 --- a/test/core/end2end/tests/request_with_flags.cc +++ b/test/core/end2end/tests/request_with_flags.cc @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/request_with_payload.cc b/test/core/end2end/tests/request_with_payload.cc index b3b9ee5726..28818c80e7 100644 --- a/test/core/end2end/tests/request_with_payload.cc +++ b/test/core/end2end/tests/request_with_payload.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc index 0ee014f97d..6d35d086aa 100644 --- a/test/core/end2end/tests/resource_quota_server.cc +++ b/test/core/end2end/tests/resource_quota_server.cc @@ -25,7 +25,7 @@ #include #include #include -#include + #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc index 743b3aeb91..f135851f86 100644 --- a/test/core/end2end/tests/server_finishes_request.cc +++ b/test/core/end2end/tests/server_finishes_request.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/shutdown_finishes_calls.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc index fce23f3b6a..2e19e059ae 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.cc +++ b/test/core/end2end/tests/shutdown_finishes_calls.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/shutdown_finishes_tags.cc b/test/core/end2end/tests/shutdown_finishes_tags.cc index de64eba612..d160647295 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.cc +++ b/test/core/end2end/tests/shutdown_finishes_tags.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_cacheable_request.cc b/test/core/end2end/tests/simple_cacheable_request.cc index d8034dcf6d..b4732aed3f 100644 --- a/test/core/end2end/tests/simple_cacheable_request.cc +++ b/test/core/end2end/tests/simple_cacheable_request.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" enum { TIMEOUT = 200000 }; diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc index 0ad224f579..54517fb242 100644 --- a/test/core/end2end/tests/simple_delayed_request.cc +++ b/test/core/end2end/tests/simple_delayed_request.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_metadata.cc b/test/core/end2end/tests/simple_metadata.cc index 1a741169d4..5911834c91 100644 --- a/test/core/end2end/tests/simple_metadata.cc +++ b/test/core/end2end/tests/simple_metadata.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index ae93f79c9d..6ec4a14959 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc index 9a384441f0..d19a60f353 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.cc +++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc index 9a27957fee..6abb3bbf5d 100644 --- a/test/core/end2end/tests/stream_compression_payload.cc +++ b/test/core/end2end/tests/stream_compression_payload.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc index 4dc306b79e..8242c2cdd1 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/streaming_error_response.cc b/test/core/end2end/tests/streaming_error_response.cc index 6ad1cec086..167530a6ae 100644 --- a/test/core/end2end/tests/streaming_error_response.cc +++ b/test/core/end2end/tests/streaming_error_response.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/trailing_metadata.cc b/test/core/end2end/tests/trailing_metadata.cc index afc56c8dfa..150c1cbd51 100644 --- a/test/core/end2end/tests/trailing_metadata.cc +++ b/test/core/end2end/tests/trailing_metadata.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc index 97ab814d27..e801e2df14 100644 --- a/test/core/end2end/tests/workaround_cronet_compression.cc +++ b/test/core/end2end/tests/workaround_cronet_compression.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/write_buffering.cc b/test/core/end2end/tests/write_buffering.cc index 40821dd6f0..7f3d1abc39 100644 --- a/test/core/end2end/tests/write_buffering.cc +++ b/test/core/end2end/tests/write_buffering.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/write_buffering_at_end.cc b/test/core/end2end/tests/write_buffering_at_end.cc index 1b9dc9632b..a1fbfef3fc 100644 --- a/test/core/end2end/tests/write_buffering_at_end.cc +++ b/test/core/end2end/tests/write_buffering_at_end.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc index c623d376f8..2d3d1b1a94 100644 --- a/test/core/fling/client.cc +++ b/test/core/fling/client.cc @@ -24,7 +24,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/profiling/timers.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc index 62a3f8bf50..087a800462 100644 --- a/test/core/gpr/arena_test.cc +++ b/test/core/gpr/arena_test.cc @@ -23,11 +23,11 @@ #include #include #include -#include #include #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); } diff --git a/test/core/gpr/avl_test.cc b/test/core/gpr/avl_test.cc index 345db557b9..0fcbbd00da 100644 --- a/test/core/gpr/avl_test.cc +++ b/test/core/gpr/avl_test.cc @@ -16,15 +16,15 @@ * */ -#include +#include "src/core/lib/gpr/avl.h" #include #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static int* box(int x) { diff --git a/test/core/gpr/cmdline_test.cc b/test/core/gpr/cmdline_test.cc index 172efda8a0..27bf0336bc 100644 --- a/test/core/gpr/cmdline_test.cc +++ b/test/core/gpr/cmdline_test.cc @@ -22,7 +22,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" #define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__) diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc index 5a8177543c..58df2f14fc 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gpr/mpscq_test.cc @@ -24,7 +24,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" typedef struct test_node { diff --git a/test/core/gpr/string_test.cc b/test/core/gpr/string_test.cc index 57068eb2c9..9f3b312465 100644 --- a/test/core/gpr/string_test.cc +++ b/test/core/gpr/string_test.cc @@ -26,7 +26,7 @@ #include #include #include -#include + #include "test/core/util/test_config.h" #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/gpr/useful_test.cc b/test/core/gpr/useful_test.cc index 2f86010d77..619c800c4d 100644 --- a/test/core/gpr/useful_test.cc +++ b/test/core/gpr/useful_test.cc @@ -18,7 +18,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" int main(int argc, char** argv) { diff --git a/test/core/http/parser_test.cc b/test/core/http/parser_test.cc index 18f19856bd..fe824f57fc 100644 --- a/test/core/http/parser_test.cc +++ b/test/core/http/parser_test.cc @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc index 891008c774..eb926cc620 100644 --- a/test/core/iomgr/combiner_test.cc +++ b/test/core/iomgr/combiner_test.cc @@ -22,8 +22,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_no_op(void) { diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc index 90dd40d9c4..4251f27c81 100644 --- a/test/core/iomgr/endpoint_pair_test.cc +++ b/test/core/iomgr/endpoint_pair_test.cc @@ -21,7 +21,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc index 8ccae52067..842be8fc92 100644 --- a/test/core/iomgr/endpoint_tests.cc +++ b/test/core/iomgr/endpoint_tests.cc @@ -25,8 +25,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/error_test.cc b/test/core/iomgr/error_test.cc index 51f8af1957..064ce0a6b2 100644 --- a/test/core/iomgr/error_test.cc +++ b/test/core/iomgr/error_test.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc index 262470300e..07a69a27c7 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.cc +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -30,8 +30,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc index 7d2f59bed4..114f39726d 100644 --- a/test/core/iomgr/pollset_set_test.cc +++ b/test/core/iomgr/pollset_set_test.cc @@ -27,8 +27,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index e36315333c..92d2338a02 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -27,8 +27,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc index 49c6f799e7..67391a547d 100644 --- a/test/core/iomgr/socket_utils_test.cc +++ b/test/core/iomgr/socket_utils_test.cc @@ -30,7 +30,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/socket_mutator.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc index f4acba8302..3a79b9b430 100644 --- a/test/core/iomgr/tcp_posix_test.cc +++ b/test/core/iomgr/tcp_posix_test.cc @@ -34,8 +34,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc index f0ab4343cb..ed66b7df8d 100644 --- a/test/core/iomgr/timer_heap_test.cc +++ b/test/core/iomgr/timer_heap_test.cc @@ -28,8 +28,8 @@ #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static gpr_atm random_deadline(void) { return rand(); } diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index 09f0283013..4c92a6b69e 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -33,9 +33,9 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/socket_factory_posix.h" diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc index c092a8f3bf..2d64520b92 100644 --- a/test/core/iomgr/wakeup_fd_cv_test.cc +++ b/test/core/iomgr/wakeup_fd_cv_test.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/test/core/json/json_rewrite_test.cc b/test/core/json/json_rewrite_test.cc index 3104afc442..8846d4612b 100644 --- a/test/core/json/json_rewrite_test.cc +++ b/test/core/json/json_rewrite_test.cc @@ -21,9 +21,9 @@ #include #include -#include #include "test/core/util/test_config.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" diff --git a/test/core/json/json_stream_error_test.cc b/test/core/json/json_stream_error_test.cc index b367d3fbf7..00288d6d5e 100644 --- a/test/core/json/json_stream_error_test.cc +++ b/test/core/json/json_stream_error_test.cc @@ -21,7 +21,6 @@ #include #include -#include #include "test/core/util/test_config.h" #include "src/core/lib/json/json_reader.h" diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc index 902f1cd90e..7f1dbb774a 100644 --- a/test/core/json/json_test.cc +++ b/test/core/json/json_test.cc @@ -21,8 +21,8 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json.h" #include "test/core/util/test_config.h" diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index ca841434aa..74618a016d 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -27,9 +27,9 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/memory_counters.h" #include "test/core/util/test_config.h" diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index fb982a10fd..628033d3c3 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -39,7 +39,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/socket_utils_posix.h" #include "test/core/util/histogram.h" diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc index 38c78fed42..8e92a21e5d 100644 --- a/test/core/security/secure_endpoint_test.cc +++ b/test/core/security/secure_endpoint_test.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/transport/secure_endpoint.h" diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index 6eaef2bf49..e4731fb039 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" diff --git a/test/core/slice/slice_string_helpers_test.cc b/test/core/slice/slice_string_helpers_test.cc index 1e38f8daca..860a1bfe03 100644 --- a/test/core/slice/slice_string_helpers_test.cc +++ b/test/core/slice/slice_string_helpers_test.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/core/util/test_config.h" diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index fefbb3c185..68129146cc 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc index 4a9e818b45..d97e98b7a4 100644 --- a/test/core/surface/completion_queue_threading_test.cc +++ b/test/core/surface/completion_queue_threading_test.cc @@ -22,7 +22,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index 36d5ad66a5..d23a3861b4 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -61,7 +60,6 @@ #include #include #include -#include #include #include @@ -243,14 +241,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_free_aligned); printf("%lx", (unsigned long) gpr_set_allocation_functions); printf("%lx", (unsigned long) gpr_get_allocation_functions); - printf("%lx", (unsigned long) gpr_avl_create); - printf("%lx", (unsigned long) gpr_avl_ref); - printf("%lx", (unsigned long) gpr_avl_unref); - printf("%lx", (unsigned long) gpr_avl_add); - printf("%lx", (unsigned long) gpr_avl_remove); - printf("%lx", (unsigned long) gpr_avl_get); - printf("%lx", (unsigned long) gpr_avl_maybe_get); - printf("%lx", (unsigned long) gpr_avl_is_empty); printf("%lx", (unsigned long) gpr_cmdline_create); printf("%lx", (unsigned long) gpr_cmdline_add_int); printf("%lx", (unsigned long) gpr_cmdline_add_flag); diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc index 3afcad7f17..c7e6b2bd84 100644 --- a/test/core/transport/bdp_estimator_test.cc +++ b/test/core/transport/bdp_estimator_test.cc @@ -22,10 +22,12 @@ #include #include #include -#include + #include #include + #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/timer_manager.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index 2aab6e9262..6947d50976 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -21,8 +21,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/pid_controller_test.cc b/test/core/transport/pid_controller_test.cc index 1a499c2fb7..8d2cec4042 100644 --- a/test/core/transport/pid_controller_test.cc +++ b/test/core/transport/pid_controller_test.cc @@ -24,7 +24,7 @@ #include #include #include -#include + #include #include "src/core/lib/gpr/string.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc index e94be138dd..26e0785488 100644 --- a/test/core/transport/timeout_encoding_test.cc +++ b/test/core/transport/timeout_encoding_test.cc @@ -24,9 +24,10 @@ #include #include #include -#include + #include "src/core/lib/gpr/murmur_hash.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc index 42e17df25d..5c92912f6f 100644 --- a/test/core/tsi/transport_security_test.cc +++ b/test/core/tsi/transport_security_test.cc @@ -23,11 +23,11 @@ #include #include #include -#include #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/tsi/fake_transport_security.h" #include "src/core/tsi/ssl_transport_security.h" #include "test/core/util/test_config.h" diff --git a/test/core/util/histogram.cc b/test/core/util/histogram.cc index 2f916f831d..b2518279ac 100644 --- a/test/core/util/histogram.cc +++ b/test/core/util/histogram.cc @@ -16,6 +16,8 @@ * */ +#include "test/core/util/histogram.h" + #include #include #include @@ -23,9 +25,8 @@ #include #include #include -#include -#include "test/core/util/histogram.h" +#include "src/core/lib/gpr/useful.h" /* Histograms are stored with exponentially increasing bucket sizes. The first bucket is [0, m) where m = 1 + resolution diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc index 7225b6dc03..c92fc0affe 100644 --- a/test/core/util/slice_splitter.cc +++ b/test/core/util/slice_splitter.cc @@ -21,7 +21,8 @@ #include #include -#include + +#include "src/core/lib/gpr/useful.h" const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) { switch (mode) { diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 6b410440c2..e381be6842 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -29,6 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" int64_t g_fixture_slowdown_factor = 1; int64_t g_poller_slowdown_factor = 1; @@ -196,7 +197,6 @@ static void install_crash_handler() { #elif GPR_POSIX_CRASH_HANDLER #include #include -#include #include #include diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc index f95ed62463..54e1cf19c9 100644 --- a/test/core/util/trickle_endpoint.cc +++ b/test/core/util/trickle_endpoint.cc @@ -26,7 +26,8 @@ #include #include #include -#include + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #define WRITE_BUFFER_SIZE (2 * 1024 * 1024) diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index f330c01281..29e225d924 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -20,9 +20,9 @@ #include #include -#include #include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_mutator.h" diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 8958b9884d..4da9639d25 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "test/cpp/interop/client_helper.h" diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc index 7a9e3ced6a..411812d583 100644 --- a/test/cpp/interop/http2_client.cc +++ b/test/cpp/interop/http2_client.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/lib/transport/byte_stream.h" #include "src/proto/grpc/testing/messages.pb.h" @@ -31,6 +30,7 @@ #include "test/cpp/interop/http2_client.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 6b59584353..eab59c72ab 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/transport/byte_stream.h" #include "src/proto/grpc/testing/empty.pb.h" diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 7cfdb2f9e9..f78a1f1d8a 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include "src/core/lib/gpr/string.h" #include "src/core/lib/transport/byte_stream.h" diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index d9d5164cce..f49f6671ae 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -21,8 +21,8 @@ #include #include #include -#include +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/port.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6873256dcd..29034ca8d9 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -910,7 +910,6 @@ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ -include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -930,7 +929,6 @@ include/grpc/support/tls.h \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ -include/grpc/support/useful.h \ include/grpc/support/workaround_list.h # This tag can be used to specify the character encoding of the source files diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 0ffbe9f73b..3ff0baaacc 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -911,7 +911,6 @@ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ -include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -931,7 +930,6 @@ include/grpc/support/tls.h \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ -include/grpc/support/useful.h \ include/grpc/support/workaround_list.h \ src/core/ext/transport/inproc/inproc_transport.h \ src/core/lib/backoff/backoff.h \ @@ -953,6 +951,7 @@ src/core/lib/debug/stats.h \ src/core/lib/debug/stats_data.h \ src/core/lib/debug/trace.h \ src/core/lib/gpr/arena.h \ +src/core/lib/gpr/avl.h \ src/core/lib/gpr/env.h \ src/core/lib/gpr/fork.h \ src/core/lib/gpr/mpscq.h \ @@ -963,6 +962,7 @@ src/core/lib/gpr/string_windows.h \ src/core/lib/gpr/thd_internal.h \ src/core/lib/gpr/time_precise.h \ src/core/lib/gpr/tmpfile.h \ +src/core/lib/gpr/useful.h \ src/core/lib/gprpp/abstract.h \ src/core/lib/gprpp/atomic.h \ src/core/lib/gprpp/atomic_with_atm.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index b28966088c..6c5bf0fe2b 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -850,7 +850,6 @@ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ -include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -870,7 +869,6 @@ include/grpc/support/tls.h \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ -include/grpc/support/useful.h \ include/grpc/support/workaround_list.h # This tag can be used to specify the character encoding of the source files diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 90ba2a76af..c929475d50 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -850,7 +850,6 @@ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ -include/grpc/support/avl.h \ include/grpc/support/cmdline.h \ include/grpc/support/cpu.h \ include/grpc/support/host_port.h \ @@ -870,7 +869,6 @@ include/grpc/support/tls.h \ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ -include/grpc/support/useful.h \ include/grpc/support/workaround_list.h \ src/core/README.md \ src/core/ext/README.md \ @@ -1074,6 +1072,7 @@ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/atm.cc \ src/core/lib/gpr/avl.cc \ +src/core/lib/gpr/avl.h \ src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ @@ -1121,6 +1120,7 @@ src/core/lib/gpr/tmpfile.h \ src/core/lib/gpr/tmpfile_msys.cc \ src/core/lib/gpr/tmpfile_posix.cc \ src/core/lib/gpr/tmpfile_windows.cc \ +src/core/lib/gpr/useful.h \ src/core/lib/gpr/wrap_memcpy.cc \ src/core/lib/gprpp/README.md \ src/core/lib/gprpp/abstract.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f414768220..c0a27cf665 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8226,7 +8226,6 @@ "include/grpc/support/atm_gcc_atomic.h", "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", - "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", @@ -8246,8 +8245,8 @@ "include/grpc/support/tls_gcc.h", "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", - "include/grpc/support/useful.h", "src/core/lib/gpr/arena.h", + "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", @@ -8258,6 +8257,7 @@ "src/core/lib/gpr/thd_internal.h", "src/core/lib/gpr/time_precise.h", "src/core/lib/gpr/tmpfile.h", + "src/core/lib/gpr/useful.h", "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/atomic_with_atm.h", @@ -8275,7 +8275,6 @@ "include/grpc/support/atm_gcc_atomic.h", "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", - "include/grpc/support/avl.h", "include/grpc/support/cmdline.h", "include/grpc/support/cpu.h", "include/grpc/support/host_port.h", @@ -8295,8 +8294,8 @@ "include/grpc/support/tls_gcc.h", "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", - "include/grpc/support/useful.h", "src/core/lib/gpr/arena.h", + "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", @@ -8307,6 +8306,7 @@ "src/core/lib/gpr/thd_internal.h", "src/core/lib/gpr/time_precise.h", "src/core/lib/gpr/tmpfile.h", + "src/core/lib/gpr/useful.h", "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/atomic_with_atm.h", -- cgit v1.2.3 From 08d9f3df3038a88d7ae69aa9e65da29e296946d2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 6 Feb 2018 07:58:17 -0800 Subject: Change Ref() methods to return a RefCountedPtr<>. --- BUILD | 2 ++ src/core/ext/filters/client_channel/subchannel.cc | 8 +++-- src/core/ext/filters/client_channel/subchannel.h | 4 ++- src/core/lib/gprpp/orphanable.h | 41 ++++++++++++++++++----- src/core/lib/gprpp/ref_counted.h | 40 +++++++++++++++++++--- src/core/lib/gprpp/ref_counted_ptr.h | 18 +++++++--- test/core/gprpp/orphanable_test.cc | 20 +++++++---- test/core/gprpp/ref_counted_ptr_test.cc | 7 ++-- test/core/gprpp/ref_counted_test.cc | 13 ++++--- 9 files changed, 119 insertions(+), 34 deletions(-) (limited to 'BUILD') diff --git a/BUILD b/BUILD index 1779575c42..78479ce787 100644 --- a/BUILD +++ b/BUILD @@ -599,6 +599,7 @@ grpc_cc_library( public_hdrs = ["src/core/lib/gprpp/orphanable.h"], deps = [ "debug_location", + "ref_counted_ptr", "gpr++_base", "grpc_trace", ], @@ -610,6 +611,7 @@ grpc_cc_library( public_hdrs = ["src/core/lib/gprpp/ref_counted.h"], deps = [ "debug_location", + "ref_counted_ptr", "gpr++_base", "grpc_trace", ], diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index dc1beee165..6bf710c948 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -738,8 +738,9 @@ grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address* addr) { } namespace grpc_core { + ConnectedSubchannel::ConnectedSubchannel(grpc_channel_stack* channel_stack) - : grpc_core::RefCountedWithTracing(&grpc_trace_stream_refcount), + : RefCountedWithTracing(&grpc_trace_stream_refcount), channel_stack_(channel_stack) {} ConnectedSubchannel::~ConnectedSubchannel() { @@ -774,7 +775,9 @@ grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args, args.arena, sizeof(grpc_subchannel_call) + channel_stack_->call_stack_size); grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call); - Ref(DEBUG_LOCATION, "subchannel_call"); + RefCountedPtr connection = + Ref(DEBUG_LOCATION, "subchannel_call"); + connection.release(); // Ref is passed to the grpc_subchannel_call object. (*call)->connection = this; const grpc_call_element_args call_args = { callstk, /* call_stack */ @@ -796,4 +799,5 @@ grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args, grpc_call_stack_set_pollset_or_pollset_set(callstk, args.pollent); return GRPC_ERROR_NONE; } + } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index b7593ec911..d2b45ae9c8 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -68,7 +68,8 @@ typedef struct grpc_subchannel_key grpc_subchannel_key; #endif namespace grpc_core { -class ConnectedSubchannel : public grpc_core::RefCountedWithTracing { + +class ConnectedSubchannel : public RefCountedWithTracing { public: struct CallArgs { grpc_polling_entity* pollent; @@ -93,6 +94,7 @@ class ConnectedSubchannel : public grpc_core::RefCountedWithTracing { private: grpc_channel_stack* channel_stack_; }; + } // namespace grpc_core grpc_subchannel* grpc_subchannel_ref( diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index 50199730c9..6e127c2861 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -28,6 +28,7 @@ #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { @@ -69,6 +70,7 @@ inline OrphanablePtr MakeOrphanable(Args&&... args) { } // A type of Orphanable with internal ref-counting. +template class InternallyRefCounted : public Orphanable { public: // Not copyable nor movable. @@ -78,10 +80,20 @@ class InternallyRefCounted : public Orphanable { GRPC_ABSTRACT_BASE_CLASS protected: + // Allow Delete() to access destructor. + template + friend void Delete(T*); + + // Allow RefCountedPtr<> to access Unref() and IncrementRefCount(). + friend class RefCountedPtr; + InternallyRefCounted() { gpr_ref_init(&refs_, 1); } virtual ~InternallyRefCounted() {} - void Ref() { gpr_ref(&refs_); } + RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + IncrementRefCount(); + return RefCountedPtr(reinterpret_cast(this)); + } void Unref() { if (gpr_unref(&refs_)) { @@ -89,11 +101,9 @@ class InternallyRefCounted : public Orphanable { } } - // Allow Delete() to access destructor. - template - friend void Delete(T*); - private: + void IncrementRefCount() { gpr_ref(&refs_); } + gpr_refcount refs_; }; @@ -103,6 +113,7 @@ class InternallyRefCounted : public Orphanable { // pointers and legacy code that is manually calling Ref() and Unref(). // Once all of our code is converted to idiomatic C++, we may be able to // eliminate this class. +template class InternallyRefCountedWithTracing : public Orphanable { public: // Not copyable nor movable. @@ -118,6 +129,9 @@ class InternallyRefCountedWithTracing : public Orphanable { template friend void Delete(T*); + // Allow RefCountedPtr<> to access Unref() and IncrementRefCount(). + friend class RefCountedPtr; + InternallyRefCountedWithTracing() : InternallyRefCountedWithTracing(static_cast(nullptr)) {} @@ -133,18 +147,27 @@ class InternallyRefCountedWithTracing : public Orphanable { virtual ~InternallyRefCountedWithTracing() {} - void Ref() { gpr_ref(&refs_); } + RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + IncrementRefCount(); + return RefCountedPtr(reinterpret_cast(this)); + } - void Ref(const DebugLocation& location, const char* reason) { + RefCountedPtr Ref(const DebugLocation& location, + const char* reason) GRPC_MUST_USE_RESULT { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); gpr_log(GPR_DEBUG, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs + 1, reason); } - Ref(); + return Ref(); } + // TODO(roth): Once all of our code is converted to C++ and can use + // RefCountedPtr<> instead of manual ref-counting, make the Unref() methods + // private, since they will only be used by RefCountedPtr<>, which is a + // friend of this class. + void Unref() { if (gpr_unref(&refs_)) { Delete(this); @@ -162,6 +185,8 @@ class InternallyRefCountedWithTracing : public Orphanable { } private: + void IncrementRefCount() { gpr_ref(&refs_); } + TraceFlag* trace_flag_ = nullptr; gpr_refcount refs_; }; diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index c68118a71a..16c7912fc6 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -26,16 +26,28 @@ #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { // A base class for reference-counted objects. // New objects should be created via New() and start with a refcount of 1. // When the refcount reaches 0, the object will be deleted via Delete(). +// +// This will commonly be used by CRTP (curiously-recurring template pattern) +// e.g., class MyClass : public RefCounted +template class RefCounted { public: - void Ref() { gpr_ref(&refs_); } + RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + IncrementRefCount(); + return RefCountedPtr(reinterpret_cast(this)); + } + // TODO(roth): Once all of our code is converted to C++ and can use + // RefCountedPtr<> instead of manual ref-counting, make this method + // private, since it will only be used by RefCountedPtr<>, which is a + // friend of this class. void Unref() { if (gpr_unref(&refs_)) { Delete(this); @@ -58,6 +70,11 @@ class RefCounted { virtual ~RefCounted() {} private: + // Allow RefCountedPtr<> to access IncrementRefCount(). + friend class RefCountedPtr; + + void IncrementRefCount() { gpr_ref(&refs_); } + gpr_refcount refs_; }; @@ -67,20 +84,30 @@ class RefCounted { // pointers and legacy code that is manually calling Ref() and Unref(). // Once all of our code is converted to idiomatic C++, we may be able to // eliminate this class. +template class RefCountedWithTracing { public: - void Ref() { gpr_ref(&refs_); } + RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + IncrementRefCount(); + return RefCountedPtr(reinterpret_cast(this)); + } - void Ref(const DebugLocation& location, const char* reason) { + RefCountedPtr Ref(const DebugLocation& location, + const char* reason) GRPC_MUST_USE_RESULT { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); gpr_log(GPR_DEBUG, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs + 1, reason); } - Ref(); + return Ref(); } + // TODO(roth): Once all of our code is converted to C++ and can use + // RefCountedPtr<> instead of manual ref-counting, make the Unref() methods + // private, since they will only be used by RefCountedPtr<>, which is a + // friend of this class. + void Unref() { if (gpr_unref(&refs_)) { Delete(this); @@ -124,6 +151,11 @@ class RefCountedWithTracing { virtual ~RefCountedWithTracing() {} private: + // Allow RefCountedPtr<> to access IncrementRefCount(). + friend class RefCountedPtr; + + void IncrementRefCount() { gpr_ref(&refs_); } + TraceFlag* trace_flag_ = nullptr; gpr_refcount refs_; }; diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index dda0f00d79..f82ba50da3 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -25,8 +25,8 @@ namespace grpc_core { -// A smart pointer class for objects that provide Ref() and Unref() methods, -// such as those provided by the RefCounted base class. +// A smart pointer class for objects that provide IncrementRefCount() and +// Unref() methods, such as those provided by the RefCounted base class. template class RefCountedPtr { public: @@ -49,13 +49,13 @@ class RefCountedPtr { // Copy support. RefCountedPtr(const RefCountedPtr& other) { - if (other.value_ != nullptr) other.value_->Ref(); + if (other.value_ != nullptr) other.value_->IncrementRefCount(); value_ = other.value_; } RefCountedPtr& operator=(const RefCountedPtr& other) { // Note: Order of reffing and unreffing is important here in case value_ // and other.value_ are the same object. - if (other.value_ != nullptr) other.value_->Ref(); + if (other.value_ != nullptr) other.value_->IncrementRefCount(); if (value_ != nullptr) value_->Unref(); value_ = other.value_; return *this; @@ -71,6 +71,16 @@ class RefCountedPtr { value_ = value; } + // TODO(roth): This method exists solely as a transition mechanism to allow + // us to pass a ref to idiomatic C code that does not use RefCountedPtr<>. + // Once all of our code has been converted to idiomatic C++, this + // method should go away. + T* release() { + T* value = value_; + value_ = nullptr; + return value; + } + T* get() const { return value_; } T& operator*() const { return *value_; } diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc index ff2f6d8bc2..ad6b9ac867 100644 --- a/test/core/gprpp/orphanable_test.cc +++ b/test/core/gprpp/orphanable_test.cc @@ -58,18 +58,19 @@ TEST(MakeOrphanable, WithParameters) { EXPECT_EQ(5, foo->value()); } -class Bar : public InternallyRefCounted { +class Bar : public InternallyRefCounted { public: Bar() : Bar(0) {} explicit Bar(int value) : value_(value) {} void Orphan() override { Unref(); } int value() const { return value_; } - void StartWork() { Ref(); } - void FinishWork() { Unref(); } + void StartWork() { self_ref_ = Ref(); } + void FinishWork() { self_ref_.reset(); } private: int value_; + RefCountedPtr self_ref_; }; TEST(OrphanablePtr, InternallyRefCounted) { @@ -82,19 +83,24 @@ TEST(OrphanablePtr, InternallyRefCounted) { // things build properly in both debug and non-debug cases. DebugOnlyTraceFlag baz_tracer(true, "baz"); -class Baz : public InternallyRefCountedWithTracing { +class Baz : public InternallyRefCountedWithTracing { public: Baz() : Baz(0) {} explicit Baz(int value) - : InternallyRefCountedWithTracing(&baz_tracer), value_(value) {} + : InternallyRefCountedWithTracing(&baz_tracer), value_(value) {} void Orphan() override { Unref(); } int value() const { return value_; } - void StartWork() { Ref(DEBUG_LOCATION, "work"); } - void FinishWork() { Unref(DEBUG_LOCATION, "work"); } + void StartWork() { self_ref_ = Ref(DEBUG_LOCATION, "work"); } + void FinishWork() { + // This is a little ugly, but it makes the logged ref and unref match up. + self_ref_.release(); + Unref(DEBUG_LOCATION, "work"); + } private: int value_; + RefCountedPtr self_ref_; }; TEST(OrphanablePtr, InternallyRefCountedWithTracing) { diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index f1f13f3183..2e398a7722 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -30,7 +30,7 @@ namespace grpc_core { namespace testing { namespace { -class Foo : public RefCounted { +class Foo : public RefCounted { public: Foo() : value_(0) {} @@ -163,14 +163,15 @@ TEST(MakeRefCounted, Args) { TraceFlag foo_tracer(true, "foo"); -class FooWithTracing : public RefCountedWithTracing { +class FooWithTracing : public RefCountedWithTracing { public: FooWithTracing() : RefCountedWithTracing(&foo_tracer) {} }; TEST(RefCountedPtr, RefCountedWithTracing) { RefCountedPtr foo(New()); - foo->Ref(DEBUG_LOCATION, "foo"); + RefCountedPtr foo2 = foo->Ref(DEBUG_LOCATION, "foo"); + foo2.release(); foo->Unref(DEBUG_LOCATION, "foo"); } diff --git a/test/core/gprpp/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc index b1b0fee5c0..f85a2e4675 100644 --- a/test/core/gprpp/ref_counted_test.cc +++ b/test/core/gprpp/ref_counted_test.cc @@ -27,7 +27,7 @@ namespace grpc_core { namespace testing { namespace { -class Foo : public RefCounted { +class Foo : public RefCounted { public: Foo() {} }; @@ -39,7 +39,8 @@ TEST(RefCounted, Basic) { TEST(RefCounted, ExtraRef) { Foo* foo = New(); - foo->Ref(); + RefCountedPtr foop = foo->Ref(); + foop.release(); foo->Unref(); foo->Unref(); } @@ -48,17 +49,19 @@ TEST(RefCounted, ExtraRef) { // things build properly in both debug and non-debug cases. DebugOnlyTraceFlag foo_tracer(true, "foo"); -class FooWithTracing : public RefCountedWithTracing { +class FooWithTracing : public RefCountedWithTracing { public: FooWithTracing() : RefCountedWithTracing(&foo_tracer) {} }; TEST(RefCountedWithTracing, Basic) { FooWithTracing* foo = New(); - foo->Ref(DEBUG_LOCATION, "extra_ref"); + RefCountedPtr foop = foo->Ref(DEBUG_LOCATION, "extra_ref"); + foop.release(); foo->Unref(DEBUG_LOCATION, "extra_ref"); // Can use the no-argument methods, too. - foo->Ref(); + foop = foo->Ref(); + foop.release(); foo->Unref(); foo->Unref(DEBUG_LOCATION, "original_ref"); } -- cgit v1.2.3 From 99f1a8f46723be31ac1de5962bc6e21ff0a560e0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Feb 2018 18:12:51 -0800 Subject: Remove compression_ruby --- BUILD | 2 - build.yaml | 2 - include/grpc/compression_ruby.h | 48 -------------------- src/core/lib/compression/compression_ruby.cc | 66 ---------------------------- src/ruby/ext/grpc/rb_compression_options.c | 5 +-- 5 files changed, 2 insertions(+), 121 deletions(-) delete mode 100644 include/grpc/compression_ruby.h delete mode 100644 src/core/lib/compression/compression_ruby.cc (limited to 'BUILD') diff --git a/BUILD b/BUILD index 78479ce787..3edcc5566f 100644 --- a/BUILD +++ b/BUILD @@ -93,7 +93,6 @@ GRPC_PUBLIC_HDRS = [ "include/grpc/byte_buffer.h", "include/grpc/byte_buffer_reader.h", "include/grpc/compression.h", - "include/grpc/compression_ruby.h", "include/grpc/fork.h", "include/grpc/grpc.h", "include/grpc/grpc_posix.h", @@ -639,7 +638,6 @@ grpc_cc_library( "src/core/lib/channel/handshaker_registry.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", - "src/core/lib/compression/compression_ruby.cc", "src/core/lib/compression/message_compress.cc", "src/core/lib/compression/stream_compression.cc", "src/core/lib/compression/stream_compression_gzip.cc", diff --git a/build.yaml b/build.yaml index eca90dd854..829081fd10 100644 --- a/build.yaml +++ b/build.yaml @@ -160,7 +160,6 @@ filegroups: - src/core/lib/channel/handshaker_registry.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - - src/core/lib/compression/compression_ruby.cc - src/core/lib/compression/message_compress.cc - src/core/lib/compression/stream_compression.cc - src/core/lib/compression/stream_compression_gzip.cc @@ -296,7 +295,6 @@ filegroups: - include/grpc/byte_buffer.h - include/grpc/byte_buffer_reader.h - include/grpc/compression.h - - include/grpc/compression_ruby.h - include/grpc/fork.h - include/grpc/grpc.h - include/grpc/grpc_posix.h diff --git a/include/grpc/compression_ruby.h b/include/grpc/compression_ruby.h deleted file mode 100644 index b063b2b529..0000000000 --- a/include/grpc/compression_ruby.h +++ /dev/null @@ -1,48 +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. - * - */ - -#ifndef GRPC_COMPRESSION_RUBY_H -#define GRPC_COMPRESSION_RUBY_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Parses the \a slice as a grpc_compression_algorithm instance and updating \a - * algorithm following algorithm names compatible with Ruby. Returns 1 upon - * success, 0 otherwise. */ -GRPCAPI int grpc_compression_algorithm_parse_ruby( - grpc_slice value, grpc_compression_algorithm* algorithm); - -/** Updates \a name with the encoding name corresponding to a valid \a - * algorithm. The \a name follows names compatible with Ruby. Note that \a name - * is statically allocated and must *not* be freed. Returns 1 upon success, 0 - * otherwise. */ -GRPCAPI int grpc_compression_algorithm_name_ruby( - grpc_compression_algorithm algorithm, const char** name); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_COMPRESSION_RUBY_H */ diff --git a/src/core/lib/compression/compression_ruby.cc b/src/core/lib/compression/compression_ruby.cc deleted file mode 100644 index 7082d6bd19..0000000000 --- a/src/core/lib/compression/compression_ruby.cc +++ /dev/null @@ -1,66 +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. - * - */ - -#include -#include - -#include "src/core/lib/surface/api_trace.h" -#include "src/core/lib/transport/static_metadata.h" - -int grpc_compression_algorithm_parse_ruby( - grpc_slice name, grpc_compression_algorithm* algorithm) { - if (grpc_slice_eq(name, GRPC_MDSTR_IDENTITY)) { - *algorithm = GRPC_COMPRESS_NONE; - return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_DEFLATE)) { - *algorithm = GRPC_COMPRESS_DEFLATE; - return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_GZIP)) { - *algorithm = GRPC_COMPRESS_GZIP; - return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_STREAM_SLASH_GZIP)) { - *algorithm = GRPC_COMPRESS_STREAM_GZIP; - return 1; - } else { - return 0; - } - return 0; -} - -int grpc_compression_algorithm_name_ruby(grpc_compression_algorithm algorithm, - const char** name) { - GRPC_API_TRACE("grpc_compression_algorithm_parse(algorithm=%d, name=%p)", 2, - ((int)algorithm, name)); - switch (algorithm) { - case GRPC_COMPRESS_NONE: - *name = "identity"; - return 1; - case GRPC_COMPRESS_DEFLATE: - *name = "deflate"; - return 1; - case GRPC_COMPRESS_GZIP: - *name = "gzip"; - return 1; - case GRPC_COMPRESS_STREAM_GZIP: - *name = "stream/gzip"; - return 1; - case GRPC_COMPRESS_ALGORITHMS_COUNT: - return 0; - } - return 0; -} diff --git a/src/ruby/ext/grpc/rb_compression_options.c b/src/ruby/ext/grpc/rb_compression_options.c index a7e37099af..e24f20d2f9 100644 --- a/src/ruby/ext/grpc/rb_compression_options.c +++ b/src/ruby/ext/grpc/rb_compression_options.c @@ -23,7 +23,6 @@ #include "rb_grpc_imports.generated.h" #include -#include #include #include #include @@ -175,7 +174,7 @@ void grpc_rb_compression_options_algorithm_name_to_value_internal( /* Raise an error if the name isn't recognized as a compression algorithm by * the algorithm parse function * in GRPC core. */ - if (!grpc_compression_algorithm_parse_ruby(name_slice, algorithm_value)) { + if (!grpc_compression_algorithm_parse(name_slice, algorithm_value)) { tmp_str = grpc_slice_to_c_string(name_slice); rb_raise(rb_eNameError, "Invalid compression algorithm name: %s", tmp_str); } @@ -287,7 +286,7 @@ VALUE grpc_rb_compression_options_algorithm_value_to_name_internal( grpc_compression_algorithm internal_value) { char* algorithm_name = NULL; - if (!grpc_compression_algorithm_name_ruby(internal_value, &algorithm_name)) { + if (!grpc_compression_algorithm_name(internal_value, &algorithm_name)) { rb_raise(rb_eArgError, "Failed to convert algorithm value to name"); } -- cgit v1.2.3 From 8f4fbb1c550c99e25f42ceafec3af92b34279db5 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 8 Feb 2018 10:04:08 -0800 Subject: Move avl to its own directory and rename it to grpc_avl --- BUILD | 4 +- CMakeLists.txt | 60 +- Makefile | 79 +- build.yaml | 23 +- config.m4 | 3 +- config.w32 | 3 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 5 +- package.xml | 4 +- .../ext/filters/client_channel/retry_throttle.cc | 16 +- .../ext/filters/client_channel/subchannel_index.cc | 46 +- src/core/lib/avl/avl.cc | 301 ++ src/core/lib/avl/avl.h | 92 + src/core/lib/gpr/avl.cc | 301 -- src/core/lib/gpr/avl.h | 92 - src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/avl/BUILD | 30 + test/core/avl/avl_test.cc | 3659 ++++++++++++++++++++ test/core/gpr/BUILD | 10 - test/core/gpr/avl_test.cc | 3659 -------------------- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 37 +- tools/run_tests/generated/tests.json | 48 +- 26 files changed, 4266 insertions(+), 4228 deletions(-) create mode 100644 src/core/lib/avl/avl.cc create mode 100644 src/core/lib/avl/avl.h delete mode 100644 src/core/lib/gpr/avl.cc delete mode 100644 src/core/lib/gpr/avl.h create mode 100644 test/core/avl/BUILD create mode 100644 test/core/avl/avl_test.cc delete mode 100644 test/core/gpr/avl_test.cc (limited to 'BUILD') diff --git a/BUILD b/BUILD index 55fc2f0ff2..4f1785d462 100644 --- a/BUILD +++ b/BUILD @@ -456,7 +456,6 @@ grpc_cc_library( "src/core/lib/gpr/alloc.cc", "src/core/lib/gpr/arena.cc", "src/core/lib/gpr/atm.cc", - "src/core/lib/gpr/avl.cc", "src/core/lib/gpr/cmdline.cc", "src/core/lib/gpr/cpu_iphone.cc", "src/core/lib/gpr/cpu_linux.cc", @@ -499,7 +498,6 @@ grpc_cc_library( hdrs = [ "src/core/lib/profiling/timers.h", "src/core/lib/gpr/arena.h", - "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", "src/core/lib/gpr/useful.h", @@ -627,6 +625,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_base_c", srcs = [ + "src/core/lib/avl/avl.cc", "src/core/lib/backoff/backoff.cc", "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", @@ -762,6 +761,7 @@ grpc_cc_library( "src/core/lib/transport/transport_op_string.cc", ], hdrs = [ + "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 782bd587f8..d582e5214b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,7 @@ add_dependencies(buildtests_c algorithm_test) add_dependencies(buildtests_c alloc_test) add_dependencies(buildtests_c alpn_test) add_dependencies(buildtests_c arena_test) +add_dependencies(buildtests_c avl_test) add_dependencies(buildtests_c bad_server_response_test) add_dependencies(buildtests_c bin_decoder_test) add_dependencies(buildtests_c bin_encoder_test) @@ -257,7 +258,6 @@ endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c goaway_server_test) endif() -add_dependencies(buildtests_c gpr_avl_test) add_dependencies(buildtests_c gpr_cmdline_test) add_dependencies(buildtests_c gpr_cpu_test) add_dependencies(buildtests_c gpr_env_test) @@ -628,7 +628,6 @@ add_library(gpr src/core/lib/gpr/alloc.cc src/core/lib/gpr/arena.cc src/core/lib/gpr/atm.cc - src/core/lib/gpr/avl.cc src/core/lib/gpr/cmdline.cc src/core/lib/gpr/cpu_iphone.cc src/core/lib/gpr/cpu_linux.cc @@ -792,6 +791,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -1134,6 +1134,7 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -1458,6 +1459,7 @@ add_library(grpc_test_util test/core/util/slice_splitter.cc test/core/util/tracer_util.cc test/core/util/trickle_endpoint.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -1726,6 +1728,7 @@ add_library(grpc_test_util_unsecure test/core/util/slice_splitter.cc test/core/util/tracer_util.cc test/core/util/trickle_endpoint.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -1977,6 +1980,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.cc src/core/lib/surface/init_unsecure.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -2709,6 +2713,7 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/stream_map.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc + src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc @@ -4832,6 +4837,32 @@ target_link_libraries(arena_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(avl_test + test/core/avl/avl_test.cc +) + + +target_include_directories(avl_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} +) + +target_link_libraries(avl_test + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr_test_util + gpr + grpc +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(bad_server_response_test test/core/end2end/bad_server_response_test.cc ) @@ -5633,31 +5664,6 @@ endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(gpr_avl_test - test/core/gpr/avl_test.cc -) - - -target_include_directories(gpr_avl_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} -) - -target_link_libraries(gpr_avl_test - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(gpr_cmdline_test test/core/gpr/cmdline_test.cc ) diff --git a/Makefile b/Makefile index 3de7410fa0..89b1d98811 100644 --- a/Makefile +++ b/Makefile @@ -955,6 +955,7 @@ alloc_test: $(BINDIR)/$(CONFIG)/alloc_test alpn_test: $(BINDIR)/$(CONFIG)/alpn_test api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer arena_test: $(BINDIR)/$(CONFIG)/arena_test +avl_test: $(BINDIR)/$(CONFIG)/avl_test bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test @@ -985,7 +986,6 @@ fling_server: $(BINDIR)/$(CONFIG)/fling_server fling_stream_test: $(BINDIR)/$(CONFIG)/fling_stream_test fling_test: $(BINDIR)/$(CONFIG)/fling_test goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test -gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test @@ -1372,6 +1372,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/alloc_test \ $(BINDIR)/$(CONFIG)/alpn_test \ $(BINDIR)/$(CONFIG)/arena_test \ + $(BINDIR)/$(CONFIG)/avl_test \ $(BINDIR)/$(CONFIG)/bad_server_response_test \ $(BINDIR)/$(CONFIG)/bin_decoder_test \ $(BINDIR)/$(CONFIG)/bin_encoder_test \ @@ -1400,7 +1401,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/fling_stream_test \ $(BINDIR)/$(CONFIG)/fling_test \ $(BINDIR)/$(CONFIG)/goaway_server_test \ - $(BINDIR)/$(CONFIG)/gpr_avl_test \ $(BINDIR)/$(CONFIG)/gpr_cmdline_test \ $(BINDIR)/$(CONFIG)/gpr_cpu_test \ $(BINDIR)/$(CONFIG)/gpr_env_test \ @@ -1812,6 +1812,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 ) $(E) "[RUN] Testing arena_test" $(Q) $(BINDIR)/$(CONFIG)/arena_test || ( echo test arena_test failed ; exit 1 ) + $(E) "[RUN] Testing avl_test" + $(Q) $(BINDIR)/$(CONFIG)/avl_test || ( echo test avl_test failed ; exit 1 ) $(E) "[RUN] Testing bad_server_response_test" $(Q) $(BINDIR)/$(CONFIG)/bad_server_response_test || ( echo test bad_server_response_test failed ; exit 1 ) $(E) "[RUN] Testing bin_decoder_test" @@ -1864,8 +1866,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/fling_test || ( echo test fling_test failed ; exit 1 ) $(E) "[RUN] Testing goaway_server_test" $(Q) $(BINDIR)/$(CONFIG)/goaway_server_test || ( echo test goaway_server_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_avl_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_avl_test || ( echo test gpr_avl_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_cmdline_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_cmdline_test || ( echo test gpr_cmdline_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_cpu_test" @@ -2874,7 +2874,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/alloc.cc \ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/atm.cc \ - src/core/lib/gpr/avl.cc \ src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ @@ -3019,6 +3018,7 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -3363,6 +3363,7 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -3688,6 +3689,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ test/core/util/trickle_endpoint.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -3949,6 +3951,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ test/core/util/trickle_endpoint.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -4180,6 +4183,7 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.cc \ src/core/lib/surface/init_unsecure.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -4913,6 +4917,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/stream_map.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -9404,6 +9409,38 @@ endif endif +AVL_TEST_SRC = \ + test/core/avl/avl_test.cc \ + +AVL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(AVL_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/avl_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/avl_test: $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/avl/avl_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a + +deps_avl_test: $(AVL_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(AVL_TEST_OBJS:.o=.dep) +endif +endif + + BAD_SERVER_RESPONSE_TEST_SRC = \ test/core/end2end/bad_server_response_test.cc \ @@ -10367,38 +10404,6 @@ endif endif -GPR_AVL_TEST_SRC = \ - test/core/gpr/avl_test.cc \ - -GPR_AVL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_AVL_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gpr_avl_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gpr_avl_test: $(GPR_AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_avl_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gpr/avl_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_gpr_avl_test: $(GPR_AVL_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GPR_AVL_TEST_OBJS:.o=.dep) -endif -endif - - GPR_CMDLINE_TEST_SRC = \ test/core/gpr/cmdline_test.cc \ diff --git a/build.yaml b/build.yaml index 516f270e73..f4ac3388ab 100644 --- a/build.yaml +++ b/build.yaml @@ -29,7 +29,6 @@ filegroups: - src/core/lib/gpr/alloc.cc - src/core/lib/gpr/arena.cc - src/core/lib/gpr/atm.cc - - src/core/lib/gpr/avl.cc - src/core/lib/gpr/cmdline.cc - src/core/lib/gpr/cpu_iphone.cc - src/core/lib/gpr/cpu_linux.cc @@ -100,7 +99,6 @@ filegroups: - include/grpc/support/tls_pthread.h headers: - src/core/lib/gpr/arena.h - - src/core/lib/gpr/avl.h - src/core/lib/gpr/env.h - src/core/lib/gpr/fork.h - src/core/lib/gpr/mpscq.h @@ -150,6 +148,7 @@ filegroups: - grpc++_codegen_base - name: grpc_base src: + - src/core/lib/avl/avl.cc - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc @@ -307,6 +306,7 @@ filegroups: - include/grpc/status.h - include/grpc/support/workaround_list.h headers: + - src/core/lib/avl/avl.h - src/core/lib/backoff/backoff.h - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h @@ -1762,6 +1762,16 @@ targets: - gpr_test_util - gpr uses_polling: false +- name: avl_test + build: test + language: c + src: + - test/core/avl/avl_test.cc + deps: + - gpr_test_util + - gpr + - grpc + uses_polling: false - name: bad_server_response_test build: test language: c @@ -2130,15 +2140,6 @@ targets: - mac - linux - posix -- name: gpr_avl_test - build: test - language: c - src: - - test/core/gpr/avl_test.cc - deps: - - gpr_test_util - - gpr - uses_polling: false - name: gpr_cmdline_test build: test language: c diff --git a/config.m4 b/config.m4 index c60c252b5c..ec48ff9619 100644 --- a/config.m4 +++ b/config.m4 @@ -42,7 +42,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/alloc.cc \ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/atm.cc \ - src/core/lib/gpr/avl.cc \ src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ @@ -84,6 +83,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/profiling/basic_timers.cc \ src/core/lib/profiling/stap_timers.cc \ src/core/lib/surface/init.cc \ + src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ @@ -626,6 +626,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression) diff --git a/config.w32 b/config.w32 index 888596bdab..9a44d1f9ec 100644 --- a/config.w32 +++ b/config.w32 @@ -19,7 +19,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\alloc.cc " + "src\\core\\lib\\gpr\\arena.cc " + "src\\core\\lib\\gpr\\atm.cc " + - "src\\core\\lib\\gpr\\avl.cc " + "src\\core\\lib\\gpr\\cmdline.cc " + "src\\core\\lib\\gpr\\cpu_iphone.cc " + "src\\core\\lib\\gpr\\cpu_linux.cc " + @@ -61,6 +60,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\profiling\\basic_timers.cc " + "src\\core\\lib\\profiling\\stap_timers.cc " + "src\\core\\lib\\surface\\init.cc " + + "src\\core\\lib\\avl\\avl.cc " + "src\\core\\lib\\backoff\\backoff.cc " + "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + @@ -638,6 +638,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 8bdb963030..7aa2998796 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -204,7 +204,6 @@ Pod::Spec.new do |s| 'src/cpp/util/time_cc.cc', 'src/cpp/codegen/codegen_init.cc', 'src/core/lib/gpr/arena.h', - 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -297,6 +296,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/inproc/inproc_transport.h', + 'src/core/lib/avl/avl.h', 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', @@ -451,7 +451,6 @@ Pod::Spec.new do |s| 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', 'src/core/lib/gpr/arena.h', - 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -470,6 +469,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/memory.h', 'src/core/lib/profiling/timers.h', + 'src/core/lib/avl/avl.h', 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index faba046cfd..ea6e95e8dd 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -192,7 +192,6 @@ Pod::Spec.new do |s| # To save you from scrolling, this is the last part of the podspec. ss.source_files = 'src/core/lib/gpr/arena.h', - 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -214,7 +213,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', - 'src/core/lib/gpr/avl.cc', 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', @@ -329,6 +327,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/inproc/inproc_transport.h', + 'src/core/lib/avl/avl.h', 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', @@ -471,6 +470,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', @@ -721,7 +721,6 @@ Pod::Spec.new do |s| 'src/core/plugin_registry/grpc_plugin_registry.cc' ss.private_header_files = 'src/core/lib/gpr/arena.h', - 'src/core/lib/gpr/avl.h', 'src/core/lib/gpr/env.h', 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', @@ -814,6 +813,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/inproc/inproc_transport.h', + 'src/core/lib/avl/avl.h', 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', diff --git a/grpc.gemspec b/grpc.gemspec index 97ba668ca9..db36cd8811 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -82,7 +82,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_posix.h ) s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( src/core/lib/gpr/arena.h ) - s.files += %w( src/core/lib/gpr/avl.h ) s.files += %w( src/core/lib/gpr/env.h ) s.files += %w( src/core/lib/gpr/fork.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) @@ -104,7 +103,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/alloc.cc ) s.files += %w( src/core/lib/gpr/arena.cc ) s.files += %w( src/core/lib/gpr/atm.cc ) - s.files += %w( src/core/lib/gpr/avl.cc ) s.files += %w( src/core/lib/gpr/cmdline.cc ) s.files += %w( src/core/lib/gpr/cpu_iphone.cc ) s.files += %w( src/core/lib/gpr/cpu_linux.cc ) @@ -255,6 +253,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/transport/inproc/inproc_transport.h ) + s.files += %w( src/core/lib/avl/avl.h ) s.files += %w( src/core/lib/backoff/backoff.h ) s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) @@ -401,6 +400,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.cc ) + s.files += %w( src/core/lib/avl/avl.cc ) s.files += %w( src/core/lib/backoff/backoff.cc ) s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) diff --git a/grpc.gyp b/grpc.gyp index 63f2eae80f..6d6ac35355 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -164,7 +164,6 @@ 'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', - 'src/core/lib/gpr/avl.cc', 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', @@ -225,6 +224,7 @@ ], 'sources': [ 'src/core/lib/surface/init.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', @@ -520,6 +520,7 @@ 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', @@ -733,6 +734,7 @@ 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', @@ -928,6 +930,7 @@ 'sources': [ 'src/core/lib/surface/init.cc', 'src/core/lib/surface/init_unsecure.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', diff --git a/package.xml b/package.xml index 438856cd69..9c298431cb 100644 --- a/package.xml +++ b/package.xml @@ -89,7 +89,6 @@ - @@ -111,7 +110,6 @@ - @@ -262,6 +260,7 @@ + @@ -408,6 +407,7 @@ + diff --git a/src/core/ext/filters/client_channel/retry_throttle.cc b/src/core/ext/filters/client_channel/retry_throttle.cc index 20d7be1c21..f632a02cde 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.cc +++ b/src/core/ext/filters/client_channel/retry_throttle.cc @@ -26,7 +26,7 @@ #include #include -#include "src/core/lib/gpr/avl.h" +#include "src/core/lib/avl/avl.h" // // server_retry_throttle_data @@ -153,7 +153,7 @@ static void* copy_server_retry_throttle_data(void* value, void* unused) { static void destroy_server_name(void* key, void* unused) { gpr_free(key); } -static const gpr_avl_vtable avl_vtable = { +static const grpc_avl_vtable avl_vtable = { destroy_server_name, copy_server_name, compare_server_name, destroy_server_retry_throttle_data, copy_server_retry_throttle_data}; @@ -162,29 +162,29 @@ static const gpr_avl_vtable avl_vtable = { // static gpr_mu g_mu; -static gpr_avl g_avl; +static grpc_avl g_avl; void grpc_retry_throttle_map_init() { gpr_mu_init(&g_mu); - g_avl = gpr_avl_create(&avl_vtable); + g_avl = grpc_avl_create(&avl_vtable); } void grpc_retry_throttle_map_shutdown() { gpr_mu_destroy(&g_mu); - gpr_avl_unref(g_avl, nullptr); + grpc_avl_unref(g_avl, nullptr); } grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server( const char* server_name, int max_milli_tokens, int milli_token_ratio) { gpr_mu_lock(&g_mu); grpc_server_retry_throttle_data* throttle_data = - (grpc_server_retry_throttle_data*)gpr_avl_get(g_avl, (char*)server_name, + (grpc_server_retry_throttle_data*)grpc_avl_get(g_avl, (char*)server_name, nullptr); if (throttle_data == nullptr) { // Entry not found. Create a new one. throttle_data = grpc_server_retry_throttle_data_create( max_milli_tokens, milli_token_ratio, nullptr); - g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data, nullptr); + g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr); } else { if (throttle_data->max_milli_tokens != max_milli_tokens || throttle_data->milli_token_ratio != milli_token_ratio) { @@ -192,7 +192,7 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server( // the original one. throttle_data = grpc_server_retry_throttle_data_create( max_milli_tokens, milli_token_ratio, throttle_data); - g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data, nullptr); + g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr); } else { // Entry found. Increase refcount. grpc_server_retry_throttle_data_ref(throttle_data); diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc index 2d063973ca..8687291bbe 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.cc +++ b/src/core/ext/filters/client_channel/subchannel_index.cc @@ -26,11 +26,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/avl.h" +#include "src/core/lib/avl/avl.h" // a map of subchannel_key --> subchannel, used for detecting connections // to the same destination in order to share them -static gpr_avl g_subchannel_index; +static grpc_avl g_subchannel_index; static gpr_mu g_mu; @@ -109,7 +109,7 @@ static void* scv_avl_copy(void* p, void* unused) { return p; } -static const gpr_avl_vtable subchannel_avl_vtable = { +static const grpc_avl_vtable subchannel_avl_vtable = { sck_avl_destroy, // destroy_key sck_avl_copy, // copy_key sck_avl_compare, // compare_keys @@ -118,7 +118,7 @@ static const gpr_avl_vtable subchannel_avl_vtable = { }; void grpc_subchannel_index_init(void) { - g_subchannel_index = gpr_avl_create(&subchannel_avl_vtable); + g_subchannel_index = grpc_avl_create(&subchannel_avl_vtable); gpr_mu_init(&g_mu); gpr_ref_init(&g_refcount, 1); } @@ -133,7 +133,7 @@ void grpc_subchannel_index_shutdown(void) { void grpc_subchannel_index_unref(void) { if (gpr_unref(&g_refcount)) { gpr_mu_destroy(&g_mu); - gpr_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get()); + grpc_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get()); } } @@ -143,13 +143,13 @@ grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key) { // Lock, and take a reference to the subchannel index. // We don't need to do the search under a lock as avl's are immutable. gpr_mu_lock(&g_mu); - gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); + grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF( - (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()), + (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get()), "index_find"); - gpr_avl_unref(index, grpc_core::ExecCtx::Get()); + grpc_avl_unref(index, grpc_core::ExecCtx::Get()); return c; } @@ -165,11 +165,11 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key, // Compare and swap loop: // - take a reference to the current index gpr_mu_lock(&g_mu); - gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); + grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); // - Check to see if a subchannel already exists - c = (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()); + c = (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get()); if (c != nullptr) { c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register"); } @@ -178,8 +178,8 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key, need_to_unref_constructed = true; } else { // no -> update the avl and compare/swap - gpr_avl updated = - gpr_avl_add(gpr_avl_ref(index, grpc_core::ExecCtx::Get()), + grpc_avl updated = + grpc_avl_add(grpc_avl_ref(index, grpc_core::ExecCtx::Get()), subchannel_key_copy(key), GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"), grpc_core::ExecCtx::Get()); @@ -189,14 +189,14 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key, // compare/swap here to check that, and retry as necessary gpr_mu_lock(&g_mu); if (index.root == g_subchannel_index.root) { - GPR_SWAP(gpr_avl, updated, g_subchannel_index); + GPR_SWAP(grpc_avl, updated, g_subchannel_index); c = constructed; } gpr_mu_unlock(&g_mu); - gpr_avl_unref(updated, grpc_core::ExecCtx::Get()); + grpc_avl_unref(updated, grpc_core::ExecCtx::Get()); } - gpr_avl_unref(index, grpc_core::ExecCtx::Get()); + grpc_avl_unref(index, grpc_core::ExecCtx::Get()); } if (need_to_unref_constructed) { @@ -213,33 +213,33 @@ void grpc_subchannel_index_unregister(grpc_subchannel_key* key, // Compare and swap loop: // - take a reference to the current index gpr_mu_lock(&g_mu); - gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); + grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); // Check to see if this key still refers to the previously // registered subchannel grpc_subchannel* c = - (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()); + (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get()); if (c != constructed) { - gpr_avl_unref(index, grpc_core::ExecCtx::Get()); + grpc_avl_unref(index, grpc_core::ExecCtx::Get()); break; } // compare and swap the update (some other thread may have // mutated the index behind us) - gpr_avl updated = - gpr_avl_remove(gpr_avl_ref(index, grpc_core::ExecCtx::Get()), key, + grpc_avl updated = + grpc_avl_remove(grpc_avl_ref(index, grpc_core::ExecCtx::Get()), key, grpc_core::ExecCtx::Get()); gpr_mu_lock(&g_mu); if (index.root == g_subchannel_index.root) { - GPR_SWAP(gpr_avl, updated, g_subchannel_index); + GPR_SWAP(grpc_avl, updated, g_subchannel_index); done = true; } gpr_mu_unlock(&g_mu); - gpr_avl_unref(updated, grpc_core::ExecCtx::Get()); - gpr_avl_unref(index, grpc_core::ExecCtx::Get()); + grpc_avl_unref(updated, grpc_core::ExecCtx::Get()); + grpc_avl_unref(index, grpc_core::ExecCtx::Get()); } } diff --git a/src/core/lib/avl/avl.cc b/src/core/lib/avl/avl.cc new file mode 100644 index 0000000000..959d12fe3a --- /dev/null +++ b/src/core/lib/avl/avl.cc @@ -0,0 +1,301 @@ +/* + * + * 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 "src/core/lib/avl/avl.h" + +#include +#include + +#include +#include + +#include "src/core/lib/gpr/useful.h" + +grpc_avl grpc_avl_create(const grpc_avl_vtable* vtable) { + grpc_avl out; + out.vtable = vtable; + out.root = nullptr; + return out; +} + +static grpc_avl_node* ref_node(grpc_avl_node* node) { + if (node) { + gpr_ref(&node->refs); + } + return node; +} + +static void unref_node(const grpc_avl_vtable* vtable, grpc_avl_node* node, + void* user_data) { + if (node == nullptr) { + return; + } + if (gpr_unref(&node->refs)) { + vtable->destroy_key(node->key, user_data); + vtable->destroy_value(node->value, user_data); + unref_node(vtable, node->left, user_data); + unref_node(vtable, node->right, user_data); + gpr_free(node); + } +} + +static long node_height(grpc_avl_node* node) { + return node == nullptr ? 0 : node->height; +} + +#ifndef NDEBUG +static long calculate_height(grpc_avl_node* node) { + return node == nullptr ? 0 + : 1 + GPR_MAX(calculate_height(node->left), + calculate_height(node->right)); +} + +static grpc_avl_node* assert_invariants(grpc_avl_node* n) { + if (n == nullptr) return nullptr; + assert_invariants(n->left); + assert_invariants(n->right); + assert(calculate_height(n) == n->height); + assert(labs(node_height(n->left) - node_height(n->right)) <= 1); + return n; +} +#else +static grpc_avl_node* assert_invariants(grpc_avl_node* n) { return n; } +#endif + +grpc_avl_node* new_node(void* key, void* value, grpc_avl_node* left, + grpc_avl_node* right) { + grpc_avl_node* node = (grpc_avl_node*)gpr_malloc(sizeof(*node)); + gpr_ref_init(&node->refs, 1); + node->key = key; + node->value = value; + node->left = assert_invariants(left); + node->right = assert_invariants(right); + node->height = 1 + GPR_MAX(node_height(left), node_height(right)); + return node; +} + +static grpc_avl_node* get(const grpc_avl_vtable* vtable, grpc_avl_node* node, + void* key, void* user_data) { + long cmp; + + if (node == nullptr) { + return nullptr; + } + + cmp = vtable->compare_keys(node->key, key, user_data); + if (cmp == 0) { + return node; + } else if (cmp > 0) { + return get(vtable, node->left, key, user_data); + } else { + return get(vtable, node->right, key, user_data); + } +} + +void* grpc_avl_get(grpc_avl avl, void* key, void* user_data) { + grpc_avl_node* node = get(avl.vtable, avl.root, key, user_data); + return node ? node->value : nullptr; +} + +int grpc_avl_maybe_get(grpc_avl avl, void* key, void** value, void* user_data) { + grpc_avl_node* node = get(avl.vtable, avl.root, key, user_data); + if (node != nullptr) { + *value = node->value; + return 1; + } + return 0; +} + +static grpc_avl_node* rotate_left(const grpc_avl_vtable* vtable, void* key, + void* value, grpc_avl_node* left, + grpc_avl_node* right, void* user_data) { + grpc_avl_node* n = new_node(vtable->copy_key(right->key, user_data), + vtable->copy_value(right->value, user_data), + new_node(key, value, left, ref_node(right->left)), + ref_node(right->right)); + unref_node(vtable, right, user_data); + return n; +} + +static grpc_avl_node* rotate_right(const grpc_avl_vtable* vtable, void* key, + void* value, grpc_avl_node* left, + grpc_avl_node* right, void* user_data) { + grpc_avl_node* n = + new_node(vtable->copy_key(left->key, user_data), + vtable->copy_value(left->value, user_data), ref_node(left->left), + new_node(key, value, ref_node(left->right), right)); + unref_node(vtable, left, user_data); + return n; +} + +static grpc_avl_node* rotate_left_right(const grpc_avl_vtable* vtable, void* key, + void* value, grpc_avl_node* left, + grpc_avl_node* right, void* user_data) { + /* rotate_right(..., rotate_left(left), right) */ + grpc_avl_node* n = + new_node(vtable->copy_key(left->right->key, user_data), + vtable->copy_value(left->right->value, user_data), + new_node(vtable->copy_key(left->key, user_data), + vtable->copy_value(left->value, user_data), + ref_node(left->left), ref_node(left->right->left)), + new_node(key, value, ref_node(left->right->right), right)); + unref_node(vtable, left, user_data); + return n; +} + +static grpc_avl_node* rotate_right_left(const grpc_avl_vtable* vtable, void* key, + void* value, grpc_avl_node* left, + grpc_avl_node* right, void* user_data) { + /* rotate_left(..., left, rotate_right(right)) */ + grpc_avl_node* n = + new_node(vtable->copy_key(right->left->key, user_data), + vtable->copy_value(right->left->value, user_data), + new_node(key, value, left, ref_node(right->left->left)), + new_node(vtable->copy_key(right->key, user_data), + vtable->copy_value(right->value, user_data), + ref_node(right->left->right), ref_node(right->right))); + unref_node(vtable, right, user_data); + return n; +} + +static grpc_avl_node* rebalance(const grpc_avl_vtable* vtable, void* key, + void* value, grpc_avl_node* left, + grpc_avl_node* right, void* user_data) { + switch (node_height(left) - node_height(right)) { + case 2: + if (node_height(left->left) - node_height(left->right) == -1) { + return assert_invariants( + rotate_left_right(vtable, key, value, left, right, user_data)); + } else { + return assert_invariants( + rotate_right(vtable, key, value, left, right, user_data)); + } + case -2: + if (node_height(right->left) - node_height(right->right) == 1) { + return assert_invariants( + rotate_right_left(vtable, key, value, left, right, user_data)); + } else { + return assert_invariants( + rotate_left(vtable, key, value, left, right, user_data)); + } + default: + return assert_invariants(new_node(key, value, left, right)); + } +} + +static grpc_avl_node* add_key(const grpc_avl_vtable* vtable, grpc_avl_node* node, + void* key, void* value, void* user_data) { + long cmp; + if (node == nullptr) { + return new_node(key, value, nullptr, nullptr); + } + cmp = vtable->compare_keys(node->key, key, user_data); + if (cmp == 0) { + return new_node(key, value, ref_node(node->left), ref_node(node->right)); + } else if (cmp > 0) { + return rebalance(vtable, vtable->copy_key(node->key, user_data), + vtable->copy_value(node->value, user_data), + add_key(vtable, node->left, key, value, user_data), + ref_node(node->right), user_data); + } else { + return rebalance( + vtable, vtable->copy_key(node->key, user_data), + vtable->copy_value(node->value, user_data), ref_node(node->left), + add_key(vtable, node->right, key, value, user_data), user_data); + } +} + +grpc_avl grpc_avl_add(grpc_avl avl, void* key, void* value, void* user_data) { + grpc_avl_node* old_root = avl.root; + avl.root = add_key(avl.vtable, avl.root, key, value, user_data); + assert_invariants(avl.root); + unref_node(avl.vtable, old_root, user_data); + return avl; +} + +static grpc_avl_node* in_order_head(grpc_avl_node* node) { + while (node->left != nullptr) { + node = node->left; + } + return node; +} + +static grpc_avl_node* in_order_tail(grpc_avl_node* node) { + while (node->right != nullptr) { + node = node->right; + } + return node; +} + +static grpc_avl_node* remove_key(const grpc_avl_vtable* vtable, + grpc_avl_node* node, void* key, + void* user_data) { + long cmp; + if (node == nullptr) { + return nullptr; + } + cmp = vtable->compare_keys(node->key, key, user_data); + if (cmp == 0) { + if (node->left == nullptr) { + return ref_node(node->right); + } else if (node->right == nullptr) { + return ref_node(node->left); + } else if (node->left->height < node->right->height) { + grpc_avl_node* h = in_order_head(node->right); + return rebalance( + vtable, vtable->copy_key(h->key, user_data), + vtable->copy_value(h->value, user_data), ref_node(node->left), + remove_key(vtable, node->right, h->key, user_data), user_data); + } else { + grpc_avl_node* h = in_order_tail(node->left); + return rebalance(vtable, vtable->copy_key(h->key, user_data), + vtable->copy_value(h->value, user_data), + remove_key(vtable, node->left, h->key, user_data), + ref_node(node->right), user_data); + } + } else if (cmp > 0) { + return rebalance(vtable, vtable->copy_key(node->key, user_data), + vtable->copy_value(node->value, user_data), + remove_key(vtable, node->left, key, user_data), + ref_node(node->right), user_data); + } else { + return rebalance( + vtable, vtable->copy_key(node->key, user_data), + vtable->copy_value(node->value, user_data), ref_node(node->left), + remove_key(vtable, node->right, key, user_data), user_data); + } +} + +grpc_avl grpc_avl_remove(grpc_avl avl, void* key, void* user_data) { + grpc_avl_node* old_root = avl.root; + avl.root = remove_key(avl.vtable, avl.root, key, user_data); + assert_invariants(avl.root); + unref_node(avl.vtable, old_root, user_data); + return avl; +} + +grpc_avl grpc_avl_ref(grpc_avl avl, void* user_data) { + ref_node(avl.root); + return avl; +} + +void grpc_avl_unref(grpc_avl avl, void* user_data) { + unref_node(avl.vtable, avl.root, user_data); +} + +int grpc_avl_is_empty(grpc_avl avl) { return avl.root == nullptr; } diff --git a/src/core/lib/avl/avl.h b/src/core/lib/avl/avl.h new file mode 100644 index 0000000000..03d9bfd7bd --- /dev/null +++ b/src/core/lib/avl/avl.h @@ -0,0 +1,92 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_GRPC_AVL_H +#define GRPC_CORE_LIB_GRPC_AVL_H + +#include + +/** internal node of an AVL tree */ +typedef struct grpc_avl_node { + gpr_refcount refs; + void* key; + void* value; + struct grpc_avl_node* left; + struct grpc_avl_node* right; + long height; +} grpc_avl_node; + +/** vtable for the AVL tree + * The optional user_data is propagated from the top level grpc_avl_XXX API. + * From the same API call, multiple vtable functions may be called multiple + * times. + */ +typedef struct grpc_avl_vtable { + /** destroy a key */ + void (*destroy_key)(void* key, void* user_data); + /** copy a key, returning new value */ + void* (*copy_key)(void* key, void* user_data); + /** compare key1, key2; return <0 if key1 < key2, + >0 if key1 > key2, 0 if key1 == key2 */ + long (*compare_keys)(void* key1, void* key2, void* user_data); + /** destroy a value */ + void (*destroy_value)(void* value, void* user_data); + /** copy a value */ + void* (*copy_value)(void* value, void* user_data); +} grpc_avl_vtable; + +/** "pointer" to an AVL tree - this is a reference + counted object - use grpc_avl_ref to add a reference, + grpc_avl_unref when done with a reference */ +typedef struct grpc_avl { + const grpc_avl_vtable* vtable; + grpc_avl_node* root; +} grpc_avl; + +/** Create an immutable AVL tree. */ +grpc_avl grpc_avl_create(const grpc_avl_vtable* vtable); +/** Add a reference to an existing tree - returns + the tree as a convenience. The optional user_data will be passed to vtable + functions. */ +grpc_avl grpc_avl_ref(grpc_avl avl, void* user_data); +/** Remove a reference to a tree - destroying it if there + are no references left. The optional user_data will be passed to vtable + functions. */ +void grpc_avl_unref(grpc_avl avl, void* user_data); +/** Return a new tree with (key, value) added to avl. + implicitly unrefs avl to allow easy chaining. + if key exists in avl, the new tree's key entry updated + (i.e. a duplicate is not created). The optional user_data will be passed to + vtable functions. */ +grpc_avl grpc_avl_add(grpc_avl avl, void* key, void* value, void* user_data); +/** Return a new tree with key deleted + implicitly unrefs avl to allow easy chaining. The optional user_data will be + passed to vtable functions. */ +grpc_avl grpc_avl_remove(grpc_avl avl, void* key, void* user_data); +/** Lookup key, and return the associated value. + Does not mutate avl. + Returns NULL if key is not found. The optional user_data will be passed to + vtable functions.*/ +void* grpc_avl_get(grpc_avl avl, void* key, void* user_data); +/** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to + its value. The optional user_data will be passed to vtable functions. */ +int grpc_avl_maybe_get(grpc_avl avl, void* key, void** value, void* user_data); +/** Return 1 if avl is empty, 0 otherwise */ +int grpc_avl_is_empty(grpc_avl avl); + +#endif /* GRPC_CORE_LIB_GRPC_AVL_H */ diff --git a/src/core/lib/gpr/avl.cc b/src/core/lib/gpr/avl.cc deleted file mode 100644 index 9d3470fe0a..0000000000 --- a/src/core/lib/gpr/avl.cc +++ /dev/null @@ -1,301 +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. - * - */ - -#include "src/core/lib/gpr/avl.h" - -#include -#include - -#include -#include - -#include "src/core/lib/gpr/useful.h" - -gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) { - gpr_avl out; - out.vtable = vtable; - out.root = nullptr; - return out; -} - -static gpr_avl_node* ref_node(gpr_avl_node* node) { - if (node) { - gpr_ref(&node->refs); - } - return node; -} - -static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node, - void* user_data) { - if (node == nullptr) { - return; - } - if (gpr_unref(&node->refs)) { - vtable->destroy_key(node->key, user_data); - vtable->destroy_value(node->value, user_data); - unref_node(vtable, node->left, user_data); - unref_node(vtable, node->right, user_data); - gpr_free(node); - } -} - -static long node_height(gpr_avl_node* node) { - return node == nullptr ? 0 : node->height; -} - -#ifndef NDEBUG -static long calculate_height(gpr_avl_node* node) { - return node == nullptr ? 0 - : 1 + GPR_MAX(calculate_height(node->left), - calculate_height(node->right)); -} - -static gpr_avl_node* assert_invariants(gpr_avl_node* n) { - if (n == nullptr) return nullptr; - assert_invariants(n->left); - assert_invariants(n->right); - assert(calculate_height(n) == n->height); - assert(labs(node_height(n->left) - node_height(n->right)) <= 1); - return n; -} -#else -static gpr_avl_node* assert_invariants(gpr_avl_node* n) { return n; } -#endif - -gpr_avl_node* new_node(void* key, void* value, gpr_avl_node* left, - gpr_avl_node* right) { - gpr_avl_node* node = (gpr_avl_node*)gpr_malloc(sizeof(*node)); - gpr_ref_init(&node->refs, 1); - node->key = key; - node->value = value; - node->left = assert_invariants(left); - node->right = assert_invariants(right); - node->height = 1 + GPR_MAX(node_height(left), node_height(right)); - return node; -} - -static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node, - void* key, void* user_data) { - long cmp; - - if (node == nullptr) { - return nullptr; - } - - cmp = vtable->compare_keys(node->key, key, user_data); - if (cmp == 0) { - return node; - } else if (cmp > 0) { - return get(vtable, node->left, key, user_data); - } else { - return get(vtable, node->right, key, user_data); - } -} - -void* gpr_avl_get(gpr_avl avl, void* key, void* user_data) { - gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data); - return node ? node->value : nullptr; -} - -int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data) { - gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data); - if (node != nullptr) { - *value = node->value; - return 1; - } - return 0; -} - -static gpr_avl_node* rotate_left(const gpr_avl_vtable* vtable, void* key, - void* value, gpr_avl_node* left, - gpr_avl_node* right, void* user_data) { - gpr_avl_node* n = new_node(vtable->copy_key(right->key, user_data), - vtable->copy_value(right->value, user_data), - new_node(key, value, left, ref_node(right->left)), - ref_node(right->right)); - unref_node(vtable, right, user_data); - return n; -} - -static gpr_avl_node* rotate_right(const gpr_avl_vtable* vtable, void* key, - void* value, gpr_avl_node* left, - gpr_avl_node* right, void* user_data) { - gpr_avl_node* n = - new_node(vtable->copy_key(left->key, user_data), - vtable->copy_value(left->value, user_data), ref_node(left->left), - new_node(key, value, ref_node(left->right), right)); - unref_node(vtable, left, user_data); - return n; -} - -static gpr_avl_node* rotate_left_right(const gpr_avl_vtable* vtable, void* key, - void* value, gpr_avl_node* left, - gpr_avl_node* right, void* user_data) { - /* rotate_right(..., rotate_left(left), right) */ - gpr_avl_node* n = - new_node(vtable->copy_key(left->right->key, user_data), - vtable->copy_value(left->right->value, user_data), - new_node(vtable->copy_key(left->key, user_data), - vtable->copy_value(left->value, user_data), - ref_node(left->left), ref_node(left->right->left)), - new_node(key, value, ref_node(left->right->right), right)); - unref_node(vtable, left, user_data); - return n; -} - -static gpr_avl_node* rotate_right_left(const gpr_avl_vtable* vtable, void* key, - void* value, gpr_avl_node* left, - gpr_avl_node* right, void* user_data) { - /* rotate_left(..., left, rotate_right(right)) */ - gpr_avl_node* n = - new_node(vtable->copy_key(right->left->key, user_data), - vtable->copy_value(right->left->value, user_data), - new_node(key, value, left, ref_node(right->left->left)), - new_node(vtable->copy_key(right->key, user_data), - vtable->copy_value(right->value, user_data), - ref_node(right->left->right), ref_node(right->right))); - unref_node(vtable, right, user_data); - return n; -} - -static gpr_avl_node* rebalance(const gpr_avl_vtable* vtable, void* key, - void* value, gpr_avl_node* left, - gpr_avl_node* right, void* user_data) { - switch (node_height(left) - node_height(right)) { - case 2: - if (node_height(left->left) - node_height(left->right) == -1) { - return assert_invariants( - rotate_left_right(vtable, key, value, left, right, user_data)); - } else { - return assert_invariants( - rotate_right(vtable, key, value, left, right, user_data)); - } - case -2: - if (node_height(right->left) - node_height(right->right) == 1) { - return assert_invariants( - rotate_right_left(vtable, key, value, left, right, user_data)); - } else { - return assert_invariants( - rotate_left(vtable, key, value, left, right, user_data)); - } - default: - return assert_invariants(new_node(key, value, left, right)); - } -} - -static gpr_avl_node* add_key(const gpr_avl_vtable* vtable, gpr_avl_node* node, - void* key, void* value, void* user_data) { - long cmp; - if (node == nullptr) { - return new_node(key, value, nullptr, nullptr); - } - cmp = vtable->compare_keys(node->key, key, user_data); - if (cmp == 0) { - return new_node(key, value, ref_node(node->left), ref_node(node->right)); - } else if (cmp > 0) { - return rebalance(vtable, vtable->copy_key(node->key, user_data), - vtable->copy_value(node->value, user_data), - add_key(vtable, node->left, key, value, user_data), - ref_node(node->right), user_data); - } else { - return rebalance( - vtable, vtable->copy_key(node->key, user_data), - vtable->copy_value(node->value, user_data), ref_node(node->left), - add_key(vtable, node->right, key, value, user_data), user_data); - } -} - -gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data) { - gpr_avl_node* old_root = avl.root; - avl.root = add_key(avl.vtable, avl.root, key, value, user_data); - assert_invariants(avl.root); - unref_node(avl.vtable, old_root, user_data); - return avl; -} - -static gpr_avl_node* in_order_head(gpr_avl_node* node) { - while (node->left != nullptr) { - node = node->left; - } - return node; -} - -static gpr_avl_node* in_order_tail(gpr_avl_node* node) { - while (node->right != nullptr) { - node = node->right; - } - return node; -} - -static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable, - gpr_avl_node* node, void* key, - void* user_data) { - long cmp; - if (node == nullptr) { - return nullptr; - } - cmp = vtable->compare_keys(node->key, key, user_data); - if (cmp == 0) { - if (node->left == nullptr) { - return ref_node(node->right); - } else if (node->right == nullptr) { - return ref_node(node->left); - } else if (node->left->height < node->right->height) { - gpr_avl_node* h = in_order_head(node->right); - return rebalance( - vtable, vtable->copy_key(h->key, user_data), - vtable->copy_value(h->value, user_data), ref_node(node->left), - remove_key(vtable, node->right, h->key, user_data), user_data); - } else { - gpr_avl_node* h = in_order_tail(node->left); - return rebalance(vtable, vtable->copy_key(h->key, user_data), - vtable->copy_value(h->value, user_data), - remove_key(vtable, node->left, h->key, user_data), - ref_node(node->right), user_data); - } - } else if (cmp > 0) { - return rebalance(vtable, vtable->copy_key(node->key, user_data), - vtable->copy_value(node->value, user_data), - remove_key(vtable, node->left, key, user_data), - ref_node(node->right), user_data); - } else { - return rebalance( - vtable, vtable->copy_key(node->key, user_data), - vtable->copy_value(node->value, user_data), ref_node(node->left), - remove_key(vtable, node->right, key, user_data), user_data); - } -} - -gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data) { - gpr_avl_node* old_root = avl.root; - avl.root = remove_key(avl.vtable, avl.root, key, user_data); - assert_invariants(avl.root); - unref_node(avl.vtable, old_root, user_data); - return avl; -} - -gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data) { - ref_node(avl.root); - return avl; -} - -void gpr_avl_unref(gpr_avl avl, void* user_data) { - unref_node(avl.vtable, avl.root, user_data); -} - -int gpr_avl_is_empty(gpr_avl avl) { return avl.root == nullptr; } diff --git a/src/core/lib/gpr/avl.h b/src/core/lib/gpr/avl.h deleted file mode 100644 index f3ab202bb7..0000000000 --- a/src/core/lib/gpr/avl.h +++ /dev/null @@ -1,92 +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. - * - */ - -#ifndef GRPC_CORE_LIB_GPR_AVL_H -#define GRPC_CORE_LIB_GPR_AVL_H - -#include - -/** internal node of an AVL tree */ -typedef struct gpr_avl_node { - gpr_refcount refs; - void* key; - void* value; - struct gpr_avl_node* left; - struct gpr_avl_node* right; - long height; -} gpr_avl_node; - -/** vtable for the AVL tree - * The optional user_data is propagated from the top level gpr_avl_XXX API. - * From the same API call, multiple vtable functions may be called multiple - * times. - */ -typedef struct gpr_avl_vtable { - /** destroy a key */ - void (*destroy_key)(void* key, void* user_data); - /** copy a key, returning new value */ - void* (*copy_key)(void* key, void* user_data); - /** compare key1, key2; return <0 if key1 < key2, - >0 if key1 > key2, 0 if key1 == key2 */ - long (*compare_keys)(void* key1, void* key2, void* user_data); - /** destroy a value */ - void (*destroy_value)(void* value, void* user_data); - /** copy a value */ - void* (*copy_value)(void* value, void* user_data); -} gpr_avl_vtable; - -/** "pointer" to an AVL tree - this is a reference - counted object - use gpr_avl_ref to add a reference, - gpr_avl_unref when done with a reference */ -typedef struct gpr_avl { - const gpr_avl_vtable* vtable; - gpr_avl_node* root; -} gpr_avl; - -/** Create an immutable AVL tree. */ -gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable); -/** Add a reference to an existing tree - returns - the tree as a convenience. The optional user_data will be passed to vtable - functions. */ -gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data); -/** Remove a reference to a tree - destroying it if there - are no references left. The optional user_data will be passed to vtable - functions. */ -void gpr_avl_unref(gpr_avl avl, void* user_data); -/** Return a new tree with (key, value) added to avl. - implicitly unrefs avl to allow easy chaining. - if key exists in avl, the new tree's key entry updated - (i.e. a duplicate is not created). The optional user_data will be passed to - vtable functions. */ -gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data); -/** Return a new tree with key deleted - implicitly unrefs avl to allow easy chaining. The optional user_data will be - passed to vtable functions. */ -gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data); -/** Lookup key, and return the associated value. - Does not mutate avl. - Returns NULL if key is not found. The optional user_data will be passed to - vtable functions.*/ -void* gpr_avl_get(gpr_avl avl, void* key, void* user_data); -/** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to - its value. The optional user_data will be passed to vtable functions. */ -int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data); -/** Return 1 if avl is empty, 0 otherwise */ -int gpr_avl_is_empty(gpr_avl avl); - -#endif /* GRPC_CORE_LIB_GPR_AVL_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 83dd5df54b..10d4454d7a 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -18,7 +18,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/arena.cc', 'src/core/lib/gpr/atm.cc', - 'src/core/lib/gpr/avl.cc', 'src/core/lib/gpr/cmdline.cc', 'src/core/lib/gpr/cpu_iphone.cc', 'src/core/lib/gpr/cpu_linux.cc', @@ -60,6 +59,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/profiling/basic_timers.cc', 'src/core/lib/profiling/stap_timers.cc', 'src/core/lib/surface/init.cc', + 'src/core/lib/avl/avl.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', diff --git a/test/core/avl/BUILD b/test/core/avl/BUILD new file mode 100644 index 0000000000..ded009071c --- /dev/null +++ b/test/core/avl/BUILD @@ -0,0 +1,30 @@ +# 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. + +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package") + +licenses(["notice"]) # Apache v2 + +grpc_package(name = "test/core/avl") + +grpc_cc_test( + name = "avl_test", + srcs = ["avl_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc_base", + "//test/core/util:gpr_test_util", + ], +) diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc new file mode 100644 index 0000000000..a290461599 --- /dev/null +++ b/test/core/avl/avl_test.cc @@ -0,0 +1,3659 @@ +/* + * + * 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 "src/core/lib/avl/avl.h" + +#include +#include + +#include +#include + +#include "src/core/lib/gpr/useful.h" +#include "test/core/util/test_config.h" + +static int* box(int x) { + int* b = static_cast(gpr_malloc(sizeof(*b))); + *b = x; + return b; +} + +static long int_compare(void* int1, void* int2, void* unused) { + return (*(int*)int1) - (*(int*)int2); +} +static void* int_copy(void* p, void* unused) { return box(*(int*)p); } + +static void destroy(void* p, void* unused) { gpr_free(p); } + +static const grpc_avl_vtable int_int_vtable = {destroy, int_copy, int_compare, + destroy, int_copy}; + +static void check_get(grpc_avl avl, int key, int value) { + int* k = box(key); + GPR_ASSERT(*(int*)grpc_avl_get(avl, k, nullptr) == value); + gpr_free(k); +} + +static void check_negget(grpc_avl avl, int key) { + int* k = box(key); + GPR_ASSERT(grpc_avl_get(avl, k, nullptr) == nullptr); + gpr_free(k); +} + +static grpc_avl remove_int(grpc_avl avl, int key) { + int* k = box(key); + avl = grpc_avl_remove(avl, k, nullptr); + gpr_free(k); + return avl; +} + +static void test_get(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_get"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(1), box(11), nullptr); + avl = grpc_avl_add(avl, box(2), box(22), nullptr); + avl = grpc_avl_add(avl, box(3), box(33), nullptr); + check_get(avl, 1, 11); + check_get(avl, 2, 22); + check_get(avl, 3, 33); + check_negget(avl, 4); + grpc_avl_unref(avl, nullptr); +} + +static void test_ll(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_ll"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(3), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_lr(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_lr"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(3), box(2), nullptr); + avl = grpc_avl_add(avl, box(4), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_rr(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_rr"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(5), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_rl(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_rl"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(5), box(2), nullptr); + avl = grpc_avl_add(avl, box(4), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_unbalanced(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_unbalanced"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(3), box(3), nullptr); + avl = grpc_avl_add(avl, box(2), box(4), nullptr); + avl = grpc_avl_add(avl, box(1), box(5), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 2); + GPR_ASSERT(*(int*)avl.root->left->left->key == 1); + GPR_ASSERT(*(int*)avl.root->left->right->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_replace(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_replace"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(1), box(1), nullptr); + avl = grpc_avl_add(avl, box(1), box(2), nullptr); + check_get(avl, 1, 2); + check_negget(avl, 2); + grpc_avl_unref(avl, nullptr); +} + +static void test_remove(void) { + grpc_avl avl; + grpc_avl avl3, avl4, avl5, avln; + gpr_log(GPR_DEBUG, "test_remove"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(5), box(3), nullptr); + + avl3 = remove_int(grpc_avl_ref(avl, nullptr), 3); + avl4 = remove_int(grpc_avl_ref(avl, nullptr), 4); + avl5 = remove_int(grpc_avl_ref(avl, nullptr), 5); + avln = remove_int(grpc_avl_ref(avl, nullptr), 1); + + grpc_avl_unref(avl, nullptr); + + check_negget(avl3, 3); + check_get(avl3, 4, 2); + check_get(avl3, 5, 3); + grpc_avl_unref(avl3, nullptr); + + check_get(avl4, 3, 1); + check_negget(avl4, 4); + check_get(avl4, 5, 3); + grpc_avl_unref(avl4, nullptr); + + check_get(avl5, 3, 1); + check_get(avl5, 4, 2); + check_negget(avl5, 5); + grpc_avl_unref(avl5, nullptr); + + check_get(avln, 3, 1); + check_get(avln, 4, 2); + check_get(avln, 5, 3); + grpc_avl_unref(avln, nullptr); +} + +static void test_badcase1(void) { + grpc_avl avl; + + gpr_log(GPR_DEBUG, "test_badcase1"); + + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(88), box(1), nullptr); + avl = remove_int(avl, 643); + avl = remove_int(avl, 983); + avl = grpc_avl_add(avl, box(985), box(4), nullptr); + avl = grpc_avl_add(avl, box(640), box(5), nullptr); + avl = grpc_avl_add(avl, box(41), box(6), nullptr); + avl = grpc_avl_add(avl, box(112), box(7), nullptr); + avl = grpc_avl_add(avl, box(342), box(8), nullptr); + avl = remove_int(avl, 1013); + avl = grpc_avl_add(avl, box(434), box(10), nullptr); + avl = grpc_avl_add(avl, box(520), box(11), nullptr); + avl = grpc_avl_add(avl, box(231), box(12), nullptr); + avl = grpc_avl_add(avl, box(852), box(13), nullptr); + avl = remove_int(avl, 461); + avl = grpc_avl_add(avl, box(108), box(15), nullptr); + avl = grpc_avl_add(avl, box(806), box(16), nullptr); + avl = grpc_avl_add(avl, box(827), box(17), nullptr); + avl = remove_int(avl, 796); + avl = grpc_avl_add(avl, box(340), box(19), nullptr); + avl = grpc_avl_add(avl, box(498), box(20), nullptr); + avl = grpc_avl_add(avl, box(203), box(21), nullptr); + avl = grpc_avl_add(avl, box(751), box(22), nullptr); + avl = grpc_avl_add(avl, box(150), box(23), nullptr); + avl = remove_int(avl, 237); + avl = grpc_avl_add(avl, box(830), box(25), nullptr); + avl = remove_int(avl, 1007); + avl = remove_int(avl, 394); + avl = grpc_avl_add(avl, box(65), box(28), nullptr); + avl = remove_int(avl, 904); + avl = remove_int(avl, 123); + avl = grpc_avl_add(avl, box(238), box(31), nullptr); + avl = grpc_avl_add(avl, box(184), box(32), nullptr); + avl = remove_int(avl, 331); + avl = grpc_avl_add(avl, box(827), box(34), nullptr); + + check_get(avl, 830, 25); + + 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; + int deletions = 0; + grpc_avl avl; + + unsigned seed = (unsigned)time(nullptr); + + gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed); + + srand((unsigned)time(nullptr)); + avl = grpc_avl_create(&int_int_vtable); + + memset(added, 0, sizeof(added)); + + for (i = 1; deletions < amount_of_stress; i++) { + int idx = rand() % (int)GPR_ARRAY_SIZE(added); + GPR_ASSERT(i); + if (rand() < RAND_MAX / 2) { + added[idx] = i; + printf("avl = grpc_avl_add(avl, box(%d), box(%d), NULL); /* d=%d */\n", + idx, i, deletions); + avl = grpc_avl_add(avl, box(idx), box(i), nullptr); + } else { + deletions += (added[idx] != 0); + added[idx] = 0; + printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions); + avl = remove_int(avl, idx); + } + for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) { + if (added[j] != 0) { + check_get(avl, j, added[j]); + } else { + check_negget(avl, j); + } + } + } + + grpc_avl_unref(avl, nullptr); +} + +int main(int argc, char* argv[]) { + grpc_test_init(argc, argv); + + test_get(); + test_ll(); + test_lr(); + test_rr(); + test_rl(); + test_unbalanced(); + test_replace(); + test_remove(); + test_badcase1(); + test_badcase2(); + test_badcase3(); + test_stress(10); + + return 0; +} diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index 1be1036d04..90ac658cdc 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -28,16 +28,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "avl_test", - srcs = ["avl_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:gpr_test_util", - ], -) - grpc_cc_test( name = "cmdline_test", srcs = ["cmdline_test.cc"], diff --git a/test/core/gpr/avl_test.cc b/test/core/gpr/avl_test.cc deleted file mode 100644 index 0fcbbd00da..0000000000 --- a/test/core/gpr/avl_test.cc +++ /dev/null @@ -1,3659 +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. - * - */ - -#include "src/core/lib/gpr/avl.h" - -#include -#include - -#include -#include - -#include "src/core/lib/gpr/useful.h" -#include "test/core/util/test_config.h" - -static int* box(int x) { - int* b = static_cast(gpr_malloc(sizeof(*b))); - *b = x; - return b; -} - -static long int_compare(void* int1, void* int2, void* unused) { - return (*(int*)int1) - (*(int*)int2); -} -static void* int_copy(void* p, void* unused) { return box(*(int*)p); } - -static void destroy(void* p, void* unused) { gpr_free(p); } - -static const gpr_avl_vtable int_int_vtable = {destroy, int_copy, int_compare, - destroy, int_copy}; - -static void check_get(gpr_avl avl, int key, int value) { - int* k = box(key); - GPR_ASSERT(*(int*)gpr_avl_get(avl, k, nullptr) == value); - gpr_free(k); -} - -static void check_negget(gpr_avl avl, int key) { - int* k = box(key); - GPR_ASSERT(gpr_avl_get(avl, k, nullptr) == nullptr); - gpr_free(k); -} - -static gpr_avl remove_int(gpr_avl avl, int key) { - int* k = box(key); - avl = gpr_avl_remove(avl, k, nullptr); - gpr_free(k); - return avl; -} - -static void test_get(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_get"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(1), box(11), nullptr); - avl = gpr_avl_add(avl, box(2), box(22), nullptr); - avl = gpr_avl_add(avl, box(3), box(33), nullptr); - check_get(avl, 1, 11); - check_get(avl, 2, 22); - check_get(avl, 3, 33); - check_negget(avl, 4); - gpr_avl_unref(avl, nullptr); -} - -static void test_ll(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_ll"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(3), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_lr(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_lr"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(3), box(2), nullptr); - avl = gpr_avl_add(avl, box(4), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_rr(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_rr"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(5), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_rl(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_rl"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(5), box(2), nullptr); - avl = gpr_avl_add(avl, box(4), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_unbalanced(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_unbalanced"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(3), box(3), nullptr); - avl = gpr_avl_add(avl, box(2), box(4), nullptr); - avl = gpr_avl_add(avl, box(1), box(5), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 2); - GPR_ASSERT(*(int*)avl.root->left->left->key == 1); - GPR_ASSERT(*(int*)avl.root->left->right->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_replace(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_replace"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(1), box(1), nullptr); - avl = gpr_avl_add(avl, box(1), box(2), nullptr); - check_get(avl, 1, 2); - check_negget(avl, 2); - gpr_avl_unref(avl, nullptr); -} - -static void test_remove(void) { - gpr_avl avl; - gpr_avl avl3, avl4, avl5, avln; - gpr_log(GPR_DEBUG, "test_remove"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(5), box(3), nullptr); - - avl3 = remove_int(gpr_avl_ref(avl, nullptr), 3); - avl4 = remove_int(gpr_avl_ref(avl, nullptr), 4); - avl5 = remove_int(gpr_avl_ref(avl, nullptr), 5); - avln = remove_int(gpr_avl_ref(avl, nullptr), 1); - - gpr_avl_unref(avl, nullptr); - - check_negget(avl3, 3); - check_get(avl3, 4, 2); - check_get(avl3, 5, 3); - gpr_avl_unref(avl3, nullptr); - - check_get(avl4, 3, 1); - check_negget(avl4, 4); - check_get(avl4, 5, 3); - gpr_avl_unref(avl4, nullptr); - - check_get(avl5, 3, 1); - check_get(avl5, 4, 2); - check_negget(avl5, 5); - gpr_avl_unref(avl5, nullptr); - - check_get(avln, 3, 1); - check_get(avln, 4, 2); - check_get(avln, 5, 3); - gpr_avl_unref(avln, nullptr); -} - -static void test_badcase1(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase1"); - - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(88), box(1), nullptr); - avl = remove_int(avl, 643); - avl = remove_int(avl, 983); - avl = gpr_avl_add(avl, box(985), box(4), nullptr); - avl = gpr_avl_add(avl, box(640), box(5), nullptr); - avl = gpr_avl_add(avl, box(41), box(6), nullptr); - avl = gpr_avl_add(avl, box(112), box(7), nullptr); - avl = gpr_avl_add(avl, box(342), box(8), nullptr); - avl = remove_int(avl, 1013); - avl = gpr_avl_add(avl, box(434), box(10), nullptr); - avl = gpr_avl_add(avl, box(520), box(11), nullptr); - avl = gpr_avl_add(avl, box(231), box(12), nullptr); - avl = gpr_avl_add(avl, box(852), box(13), nullptr); - avl = remove_int(avl, 461); - avl = gpr_avl_add(avl, box(108), box(15), nullptr); - avl = gpr_avl_add(avl, box(806), box(16), nullptr); - avl = gpr_avl_add(avl, box(827), box(17), nullptr); - avl = remove_int(avl, 796); - avl = gpr_avl_add(avl, box(340), box(19), nullptr); - avl = gpr_avl_add(avl, box(498), box(20), nullptr); - avl = gpr_avl_add(avl, box(203), box(21), nullptr); - avl = gpr_avl_add(avl, box(751), box(22), nullptr); - avl = gpr_avl_add(avl, box(150), box(23), nullptr); - avl = remove_int(avl, 237); - avl = gpr_avl_add(avl, box(830), box(25), nullptr); - avl = remove_int(avl, 1007); - avl = remove_int(avl, 394); - avl = gpr_avl_add(avl, box(65), box(28), nullptr); - avl = remove_int(avl, 904); - avl = remove_int(avl, 123); - avl = gpr_avl_add(avl, box(238), box(31), nullptr); - avl = gpr_avl_add(avl, box(184), box(32), nullptr); - avl = remove_int(avl, 331); - avl = gpr_avl_add(avl, box(827), box(34), nullptr); - - check_get(avl, 830, 25); - - gpr_avl_unref(avl, nullptr); -} - -static void test_badcase2(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase2"); - - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(288), box(1), nullptr); - avl = remove_int(avl, 415); - avl = gpr_avl_add(avl, box(953), box(3), nullptr); - avl = gpr_avl_add(avl, box(101), box(4), nullptr); - avl = gpr_avl_add(avl, box(516), box(5), nullptr); - avl = gpr_avl_add(avl, box(547), box(6), nullptr); - avl = gpr_avl_add(avl, box(467), box(7), nullptr); - avl = gpr_avl_add(avl, box(793), box(8), nullptr); - avl = remove_int(avl, 190); - avl = gpr_avl_add(avl, box(687), box(10), nullptr); - avl = gpr_avl_add(avl, box(242), box(11), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(950), box(17), nullptr); - avl = gpr_avl_add(avl, box(622), box(18), nullptr); - avl = remove_int(avl, 513); - avl = remove_int(avl, 429); - avl = gpr_avl_add(avl, box(205), box(21), nullptr); - avl = remove_int(avl, 663); - avl = remove_int(avl, 953); - avl = remove_int(avl, 892); - avl = gpr_avl_add(avl, box(236), box(25), nullptr); - avl = remove_int(avl, 982); - avl = remove_int(avl, 201); - avl = remove_int(avl, 684); - avl = gpr_avl_add(avl, box(572), box(29), nullptr); - avl = remove_int(avl, 817); - avl = gpr_avl_add(avl, box(970), box(31), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 574); - avl = gpr_avl_add(avl, box(752), box(34), nullptr); - avl = gpr_avl_add(avl, box(670), box(35), nullptr); - avl = gpr_avl_add(avl, box(69), box(36), nullptr); - avl = remove_int(avl, 111); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(141), box(39), nullptr); - avl = remove_int(avl, 159); - avl = gpr_avl_add(avl, box(947), box(41), nullptr); - avl = gpr_avl_add(avl, box(855), box(42), nullptr); - avl = remove_int(avl, 218); - avl = remove_int(avl, 6); - avl = gpr_avl_add(avl, box(753), box(45), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 799); - avl = gpr_avl_add(avl, box(572), box(48), nullptr); - avl = remove_int(avl, 376); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(458), box(51), nullptr); - avl = remove_int(avl, 897); - avl = gpr_avl_add(avl, box(191), box(53), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(871), box(60), nullptr); - avl = remove_int(avl, 641); - avl = gpr_avl_add(avl, box(462), box(62), nullptr); - avl = remove_int(avl, 359); - avl = remove_int(avl, 767); - avl = gpr_avl_add(avl, box(310), box(65), nullptr); - avl = remove_int(avl, 757); - avl = remove_int(avl, 639); - avl = remove_int(avl, 314); - avl = gpr_avl_add(avl, box(2), box(69), nullptr); - avl = remove_int(avl, 138); - avl = gpr_avl_add(avl, box(669), box(71), nullptr); - avl = remove_int(avl, 477); - avl = gpr_avl_add(avl, box(366), box(73), nullptr); - avl = gpr_avl_add(avl, box(612), box(74), nullptr); - avl = gpr_avl_add(avl, box(106), box(75), nullptr); - avl = remove_int(avl, 161); - avl = gpr_avl_add(avl, box(388), box(77), nullptr); - avl = gpr_avl_add(avl, box(141), box(78), nullptr); - avl = remove_int(avl, 633); - avl = remove_int(avl, 459); - avl = gpr_avl_add(avl, box(40), box(81), nullptr); - avl = remove_int(avl, 689); - avl = gpr_avl_add(avl, box(823), box(83), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(903), box(85), nullptr); - avl = gpr_avl_add(avl, box(592), box(86), nullptr); - avl = remove_int(avl, 448); - avl = gpr_avl_add(avl, box(56), box(88), nullptr); - avl = remove_int(avl, 333); - avl = gpr_avl_add(avl, box(189), box(90), nullptr); - avl = gpr_avl_add(avl, box(103), box(91), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 974); - avl = gpr_avl_add(avl, box(215), box(94), nullptr); - avl = remove_int(avl, 189); - avl = remove_int(avl, 504); - avl = gpr_avl_add(avl, box(868), box(97), nullptr); - avl = remove_int(avl, 909); - avl = remove_int(avl, 148); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(994), box(101), nullptr); - avl = gpr_avl_add(avl, box(576), box(102), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 209); - avl = gpr_avl_add(avl, box(276), box(105), nullptr); - avl = remove_int(avl, 856); - avl = gpr_avl_add(avl, box(750), box(107), nullptr); - avl = remove_int(avl, 871); - avl = gpr_avl_add(avl, box(301), box(109), nullptr); - avl = remove_int(avl, 260); - avl = remove_int(avl, 737); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(933), box(113), nullptr); - avl = gpr_avl_add(avl, box(225), box(114), nullptr); - avl = gpr_avl_add(avl, box(975), box(115), nullptr); - avl = gpr_avl_add(avl, box(86), box(116), nullptr); - avl = remove_int(avl, 732); - avl = gpr_avl_add(avl, box(340), box(118), nullptr); - avl = gpr_avl_add(avl, box(271), box(119), nullptr); - avl = remove_int(avl, 206); - avl = gpr_avl_add(avl, box(949), box(121), nullptr); - avl = gpr_avl_add(avl, box(927), box(122), nullptr); - avl = gpr_avl_add(avl, box(34), box(123), nullptr); - avl = gpr_avl_add(avl, box(351), box(124), nullptr); - avl = remove_int(avl, 836); - avl = gpr_avl_add(avl, box(825), box(126), nullptr); - avl = gpr_avl_add(avl, box(352), box(127), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 101); - avl = gpr_avl_add(avl, box(320), box(130), nullptr); - avl = gpr_avl_add(avl, box(3), box(131), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 44); - avl = gpr_avl_add(avl, box(525), box(134), nullptr); - avl = gpr_avl_add(avl, box(864), box(135), nullptr); - avl = gpr_avl_add(avl, box(863), box(136), nullptr); - avl = remove_int(avl, 770); - avl = gpr_avl_add(avl, box(440), box(138), nullptr); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(116), box(140), nullptr); - avl = remove_int(avl, 380); - avl = gpr_avl_add(avl, box(878), box(142), nullptr); - avl = remove_int(avl, 439); - avl = gpr_avl_add(avl, box(994), box(144), nullptr); - avl = remove_int(avl, 294); - avl = remove_int(avl, 593); - avl = gpr_avl_add(avl, box(696), box(147), nullptr); - avl = remove_int(avl, 8); - avl = gpr_avl_add(avl, box(881), box(149), nullptr); - avl = remove_int(avl, 32); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(487), box(152), nullptr); - avl = gpr_avl_add(avl, box(637), box(153), nullptr); - avl = gpr_avl_add(avl, box(793), box(154), nullptr); - avl = gpr_avl_add(avl, box(696), box(155), nullptr); - avl = remove_int(avl, 458); - avl = gpr_avl_add(avl, box(828), box(157), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 274); - avl = gpr_avl_add(avl, box(783), box(160), nullptr); - avl = remove_int(avl, 21); - avl = gpr_avl_add(avl, box(866), box(162), nullptr); - avl = remove_int(avl, 919); - avl = gpr_avl_add(avl, box(435), box(164), nullptr); - avl = remove_int(avl, 385); - avl = gpr_avl_add(avl, box(475), box(166), nullptr); - avl = remove_int(avl, 339); - avl = gpr_avl_add(avl, box(615), box(168), nullptr); - avl = remove_int(avl, 866); - avl = remove_int(avl, 82); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(590), box(172), nullptr); - avl = gpr_avl_add(avl, box(852), box(173), nullptr); - avl = remove_int(avl, 318); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(672), box(176), nullptr); - avl = remove_int(avl, 430); - avl = gpr_avl_add(avl, box(821), box(178), nullptr); - avl = gpr_avl_add(avl, box(365), box(179), nullptr); - avl = remove_int(avl, 78); - avl = gpr_avl_add(avl, box(700), box(181), nullptr); - avl = gpr_avl_add(avl, box(353), box(182), nullptr); - avl = remove_int(avl, 492); - avl = gpr_avl_add(avl, box(991), box(184), nullptr); - avl = remove_int(avl, 330); - avl = gpr_avl_add(avl, box(873), box(186), nullptr); - avl = remove_int(avl, 589); - avl = gpr_avl_add(avl, box(676), box(188), nullptr); - avl = gpr_avl_add(avl, box(790), box(189), nullptr); - avl = remove_int(avl, 521); - avl = remove_int(avl, 47); - avl = gpr_avl_add(avl, box(976), box(192), nullptr); - avl = gpr_avl_add(avl, box(683), box(193), nullptr); - avl = remove_int(avl, 803); - avl = remove_int(avl, 1006); - avl = gpr_avl_add(avl, box(775), box(196), nullptr); - avl = gpr_avl_add(avl, box(411), box(197), nullptr); - avl = gpr_avl_add(avl, box(697), box(198), nullptr); - avl = remove_int(avl, 50); - avl = gpr_avl_add(avl, box(213), box(200), nullptr); - avl = remove_int(avl, 714); - avl = gpr_avl_add(avl, box(981), box(202), nullptr); - avl = gpr_avl_add(avl, box(502), box(203), nullptr); - avl = gpr_avl_add(avl, box(697), box(204), nullptr); - avl = gpr_avl_add(avl, box(603), box(205), nullptr); - avl = gpr_avl_add(avl, box(117), box(206), nullptr); - avl = remove_int(avl, 363); - avl = gpr_avl_add(avl, box(104), box(208), nullptr); - avl = remove_int(avl, 842); - avl = gpr_avl_add(avl, box(48), box(210), nullptr); - avl = remove_int(avl, 764); - avl = gpr_avl_add(avl, box(482), box(212), nullptr); - avl = gpr_avl_add(avl, box(928), box(213), nullptr); - avl = gpr_avl_add(avl, box(30), box(214), nullptr); - avl = gpr_avl_add(avl, box(820), box(215), nullptr); - avl = gpr_avl_add(avl, box(334), box(216), nullptr); - avl = remove_int(avl, 306); - avl = gpr_avl_add(avl, box(789), box(218), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(53), box(220), nullptr); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(130), box(222), nullptr); - avl = gpr_avl_add(avl, box(239), box(223), nullptr); - avl = remove_int(avl, 20); - avl = gpr_avl_add(avl, box(117), box(225), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 891); - avl = gpr_avl_add(avl, box(9), box(228), nullptr); - avl = gpr_avl_add(avl, box(496), box(229), nullptr); - avl = gpr_avl_add(avl, box(750), box(230), nullptr); - avl = gpr_avl_add(avl, box(283), box(231), nullptr); - avl = gpr_avl_add(avl, box(802), box(232), nullptr); - avl = remove_int(avl, 352); - avl = gpr_avl_add(avl, box(374), box(234), nullptr); - avl = gpr_avl_add(avl, box(6), box(235), nullptr); - avl = gpr_avl_add(avl, box(756), box(236), nullptr); - avl = gpr_avl_add(avl, box(597), box(237), nullptr); - avl = gpr_avl_add(avl, box(661), box(238), nullptr); - avl = remove_int(avl, 96); - avl = gpr_avl_add(avl, box(894), box(240), nullptr); - avl = remove_int(avl, 749); - avl = gpr_avl_add(avl, box(71), box(242), nullptr); - avl = remove_int(avl, 68); - avl = gpr_avl_add(avl, box(388), box(244), nullptr); - avl = remove_int(avl, 119); - avl = remove_int(avl, 856); - avl = gpr_avl_add(avl, box(176), box(247), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(779), box(257), nullptr); - avl = gpr_avl_add(avl, box(484), box(258), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(388), box(260), nullptr); - avl = remove_int(avl, 987); - avl = gpr_avl_add(avl, box(336), box(262), nullptr); - avl = remove_int(avl, 855); - avl = gpr_avl_add(avl, box(668), box(264), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(193), box(266), nullptr); - avl = remove_int(avl, 939); - avl = gpr_avl_add(avl, box(740), box(268), nullptr); - avl = gpr_avl_add(avl, box(503), box(269), nullptr); - avl = gpr_avl_add(avl, box(765), box(270), nullptr); - avl = remove_int(avl, 924); - avl = remove_int(avl, 513); - avl = gpr_avl_add(avl, box(161), box(273), nullptr); - avl = gpr_avl_add(avl, box(502), box(274), nullptr); - avl = gpr_avl_add(avl, box(846), box(275), nullptr); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(87), box(277), nullptr); - avl = gpr_avl_add(avl, box(949), box(278), nullptr); - avl = gpr_avl_add(avl, box(548), box(279), nullptr); - avl = gpr_avl_add(avl, box(951), box(280), nullptr); - avl = remove_int(avl, 1018); - avl = remove_int(avl, 568); - avl = gpr_avl_add(avl, box(138), box(283), nullptr); - avl = gpr_avl_add(avl, box(202), box(284), nullptr); - avl = gpr_avl_add(avl, box(157), box(285), nullptr); - avl = gpr_avl_add(avl, box(264), box(286), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(876), box(295), nullptr); - avl = remove_int(avl, 354); - avl = gpr_avl_add(avl, box(134), box(297), nullptr); - avl = remove_int(avl, 781); - avl = remove_int(avl, 183); - avl = gpr_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 = gpr_avl_add(avl, box(208), box(306), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(58), box(314), nullptr); - avl = gpr_avl_add(avl, box(265), box(315), nullptr); - avl = gpr_avl_add(avl, box(268), box(316), nullptr); - avl = gpr_avl_add(avl, box(103), box(317), nullptr); - avl = gpr_avl_add(avl, box(440), box(318), nullptr); - avl = remove_int(avl, 777); - avl = gpr_avl_add(avl, box(670), box(320), nullptr); - avl = remove_int(avl, 506); - avl = remove_int(avl, 487); - avl = gpr_avl_add(avl, box(421), box(323), nullptr); - avl = remove_int(avl, 514); - avl = gpr_avl_add(avl, box(701), box(325), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 872); - avl = remove_int(avl, 139); - avl = gpr_avl_add(avl, box(781), box(329), nullptr); - avl = gpr_avl_add(avl, box(543), box(330), nullptr); - avl = gpr_avl_add(avl, box(147), box(331), nullptr); - avl = remove_int(avl, 190); - avl = gpr_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 = gpr_avl_add(avl, box(514), box(338), nullptr); - avl = remove_int(avl, 812); - avl = gpr_avl_add(avl, box(431), box(340), nullptr); - avl = gpr_avl_add(avl, box(8), box(341), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(831), box(343), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 157); - avl = gpr_avl_add(avl, box(612), box(346), nullptr); - avl = gpr_avl_add(avl, box(802), box(347), nullptr); - avl = remove_int(avl, 554); - avl = gpr_avl_add(avl, box(409), box(349), nullptr); - avl = gpr_avl_add(avl, box(439), box(350), nullptr); - avl = gpr_avl_add(avl, box(725), box(351), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(435), box(357), nullptr); - avl = gpr_avl_add(avl, box(950), box(358), nullptr); - avl = gpr_avl_add(avl, box(532), box(359), nullptr); - avl = gpr_avl_add(avl, box(832), box(360), nullptr); - avl = remove_int(avl, 390); - avl = gpr_avl_add(avl, box(993), box(362), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 401); - avl = gpr_avl_add(avl, box(316), box(365), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(541), box(367), nullptr); - avl = gpr_avl_add(avl, box(505), box(368), nullptr); - avl = remove_int(avl, 445); - avl = remove_int(avl, 256); - avl = gpr_avl_add(avl, box(232), box(371), nullptr); - avl = remove_int(avl, 577); - avl = remove_int(avl, 558); - avl = gpr_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 = gpr_avl_add(avl, box(920), box(380), nullptr); - avl = gpr_avl_add(avl, box(655), box(381), nullptr); - avl = remove_int(avl, 557); - avl = remove_int(avl, 102); - avl = remove_int(avl, 165); - avl = gpr_avl_add(avl, box(191), box(385), nullptr); - avl = remove_int(avl, 30); - avl = gpr_avl_add(avl, box(406), box(387), nullptr); - avl = gpr_avl_add(avl, box(66), box(388), nullptr); - avl = gpr_avl_add(avl, box(87), box(389), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 671); - avl = gpr_avl_add(avl, box(234), box(392), nullptr); - avl = remove_int(avl, 463); - avl = gpr_avl_add(avl, box(75), box(394), nullptr); - avl = gpr_avl_add(avl, box(487), box(395), nullptr); - avl = remove_int(avl, 203); - avl = gpr_avl_add(avl, box(711), box(397), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 798); - avl = remove_int(avl, 337); - avl = gpr_avl_add(avl, box(877), box(401), nullptr); - avl = gpr_avl_add(avl, box(388), box(402), nullptr); - avl = remove_int(avl, 975); - avl = gpr_avl_add(avl, box(200), box(404), nullptr); - avl = gpr_avl_add(avl, box(408), box(405), nullptr); - avl = gpr_avl_add(avl, box(3), box(406), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(492), box(412), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 364); - avl = gpr_avl_add(avl, box(215), box(415), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 45); - avl = gpr_avl_add(avl, box(328), box(418), nullptr); - avl = gpr_avl_add(avl, box(597), box(419), nullptr); - avl = remove_int(avl, 34); - avl = gpr_avl_add(avl, box(736), box(421), nullptr); - avl = remove_int(avl, 37); - avl = gpr_avl_add(avl, box(275), box(423), nullptr); - avl = gpr_avl_add(avl, box(70), box(424), nullptr); - avl = gpr_avl_add(avl, box(771), box(425), nullptr); - avl = remove_int(avl, 536); - avl = remove_int(avl, 421); - avl = gpr_avl_add(avl, box(186), box(428), nullptr); - avl = gpr_avl_add(avl, box(788), box(429), nullptr); - avl = gpr_avl_add(avl, box(224), box(430), nullptr); - avl = remove_int(avl, 228); - avl = gpr_avl_add(avl, box(48), box(432), nullptr); - avl = gpr_avl_add(avl, box(120), box(433), nullptr); - avl = gpr_avl_add(avl, box(269), box(434), nullptr); - avl = gpr_avl_add(avl, box(904), box(435), nullptr); - avl = remove_int(avl, 699); - avl = gpr_avl_add(avl, box(340), box(437), nullptr); - avl = remove_int(avl, 276); - avl = gpr_avl_add(avl, box(591), box(439), nullptr); - avl = gpr_avl_add(avl, box(778), box(440), nullptr); - avl = remove_int(avl, 490); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(294), box(443), nullptr); - avl = gpr_avl_add(avl, box(323), box(444), nullptr); - avl = remove_int(avl, 685); - avl = gpr_avl_add(avl, box(38), box(446), nullptr); - avl = gpr_avl_add(avl, box(525), box(447), nullptr); - avl = remove_int(avl, 162); - avl = gpr_avl_add(avl, box(462), box(449), nullptr); - avl = gpr_avl_add(avl, box(340), box(450), nullptr); - avl = remove_int(avl, 734); - avl = remove_int(avl, 959); - avl = gpr_avl_add(avl, box(752), box(453), nullptr); - avl = gpr_avl_add(avl, box(667), box(454), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(711), box(457), nullptr); - avl = remove_int(avl, 937); - avl = gpr_avl_add(avl, box(741), box(459), nullptr); - avl = gpr_avl_add(avl, box(40), box(460), nullptr); - avl = remove_int(avl, 784); - avl = gpr_avl_add(avl, box(292), box(462), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 931); - avl = remove_int(avl, 886); - avl = gpr_avl_add(avl, box(968), box(466), nullptr); - avl = remove_int(avl, 263); - avl = gpr_avl_add(avl, box(647), box(468), nullptr); - avl = gpr_avl_add(avl, box(92), box(469), nullptr); - avl = remove_int(avl, 310); - avl = gpr_avl_add(avl, box(711), box(471), nullptr); - avl = gpr_avl_add(avl, box(675), box(472), nullptr); - avl = remove_int(avl, 549); - avl = gpr_avl_add(avl, box(380), box(474), nullptr); - avl = remove_int(avl, 825); - avl = gpr_avl_add(avl, box(668), box(476), nullptr); - avl = remove_int(avl, 498); - avl = gpr_avl_add(avl, box(870), box(478), nullptr); - avl = gpr_avl_add(avl, box(391), box(479), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(508), box(487), nullptr); - avl = remove_int(avl, 849); - avl = remove_int(avl, 47); - avl = gpr_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 = gpr_avl_add(avl, box(33), box(495), nullptr); - avl = gpr_avl_add(avl, box(524), box(496), nullptr); - avl = remove_int(avl, 210); - avl = remove_int(avl, 299); - avl = gpr_avl_add(avl, box(823), box(499), nullptr); - avl = remove_int(avl, 479); - avl = remove_int(avl, 96); - avl = remove_int(avl, 1013); - avl = gpr_avl_add(avl, box(768), box(503), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 20); - avl = gpr_avl_add(avl, box(663), box(506), nullptr); - avl = remove_int(avl, 882); - avl = gpr_avl_add(avl, box(745), box(508), nullptr); - avl = remove_int(avl, 352); - avl = gpr_avl_add(avl, box(10), box(510), nullptr); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(420), box(512), nullptr); - avl = gpr_avl_add(avl, box(884), box(513), nullptr); - avl = gpr_avl_add(avl, box(993), box(514), nullptr); - avl = gpr_avl_add(avl, box(251), box(515), nullptr); - avl = remove_int(avl, 222); - avl = gpr_avl_add(avl, box(734), box(517), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(77), box(524), nullptr); - avl = remove_int(avl, 897); - avl = gpr_avl_add(avl, box(719), box(526), nullptr); - avl = gpr_avl_add(avl, box(622), box(527), nullptr); - avl = remove_int(avl, 28); - avl = remove_int(avl, 836); - avl = remove_int(avl, 142); - avl = gpr_avl_add(avl, box(445), box(531), nullptr); - avl = gpr_avl_add(avl, box(410), box(532), nullptr); - avl = remove_int(avl, 575); - avl = gpr_avl_add(avl, box(634), box(534), nullptr); - avl = gpr_avl_add(avl, box(906), box(535), nullptr); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(813), box(537), nullptr); - avl = remove_int(avl, 702); - avl = remove_int(avl, 732); - avl = gpr_avl_add(avl, box(105), box(540), nullptr); - avl = gpr_avl_add(avl, box(867), box(541), nullptr); - avl = remove_int(avl, 964); - avl = remove_int(avl, 941); - avl = gpr_avl_add(avl, box(947), box(544), nullptr); - avl = remove_int(avl, 990); - avl = gpr_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 = gpr_avl_add(avl, box(57), box(551), nullptr); - avl = gpr_avl_add(avl, box(786), box(552), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(528), box(558), nullptr); - avl = gpr_avl_add(avl, box(749), box(559), nullptr); - avl = gpr_avl_add(avl, box(194), box(560), nullptr); - avl = remove_int(avl, 517); - avl = gpr_avl_add(avl, box(102), box(562), nullptr); - avl = remove_int(avl, 189); - avl = gpr_avl_add(avl, box(927), box(564), nullptr); - avl = remove_int(avl, 846); - avl = remove_int(avl, 130); - avl = gpr_avl_add(avl, box(694), box(567), nullptr); - avl = remove_int(avl, 750); - avl = gpr_avl_add(avl, box(357), box(569), nullptr); - avl = remove_int(avl, 431); - avl = remove_int(avl, 91); - avl = gpr_avl_add(avl, box(640), box(572), nullptr); - avl = remove_int(avl, 4); - avl = gpr_avl_add(avl, box(81), box(574), nullptr); - avl = gpr_avl_add(avl, box(595), box(575), nullptr); - avl = remove_int(avl, 444); - avl = remove_int(avl, 262); - avl = remove_int(avl, 11); - avl = gpr_avl_add(avl, box(192), box(579), nullptr); - avl = gpr_avl_add(avl, box(158), box(580), nullptr); - avl = remove_int(avl, 401); - avl = remove_int(avl, 918); - avl = gpr_avl_add(avl, box(180), box(583), nullptr); - avl = remove_int(avl, 268); - avl = gpr_avl_add(avl, box(1012), box(585), nullptr); - avl = gpr_avl_add(avl, box(90), box(586), nullptr); - avl = gpr_avl_add(avl, box(946), box(587), nullptr); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(874), box(589), nullptr); - avl = gpr_avl_add(avl, box(679), box(590), nullptr); - avl = remove_int(avl, 53); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(646), box(593), nullptr); - avl = gpr_avl_add(avl, box(767), box(594), nullptr); - avl = gpr_avl_add(avl, box(460), box(595), nullptr); - avl = gpr_avl_add(avl, box(852), box(596), nullptr); - avl = gpr_avl_add(avl, box(189), box(597), nullptr); - avl = remove_int(avl, 932); - avl = remove_int(avl, 366); - avl = remove_int(avl, 907); - avl = gpr_avl_add(avl, box(875), box(601), nullptr); - avl = gpr_avl_add(avl, box(434), box(602), nullptr); - avl = gpr_avl_add(avl, box(704), box(603), nullptr); - avl = gpr_avl_add(avl, box(724), box(604), nullptr); - avl = gpr_avl_add(avl, box(930), box(605), nullptr); - avl = gpr_avl_add(avl, box(1000), box(606), nullptr); - avl = remove_int(avl, 479); - avl = gpr_avl_add(avl, box(275), box(608), nullptr); - avl = remove_int(avl, 32); - avl = gpr_avl_add(avl, box(939), box(610), nullptr); - avl = remove_int(avl, 943); - avl = remove_int(avl, 329); - avl = gpr_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 = gpr_avl_add(avl, box(40), box(618), nullptr); - avl = remove_int(avl, 751); - avl = gpr_avl_add(avl, box(568), box(620), nullptr); - avl = gpr_avl_add(avl, box(120), box(621), nullptr); - avl = gpr_avl_add(avl, box(617), box(622), nullptr); - avl = gpr_avl_add(avl, box(32), box(623), nullptr); - avl = remove_int(avl, 701); - avl = gpr_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 = gpr_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 = gpr_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 = gpr_avl_add(avl, box(552), box(641), nullptr); - avl = gpr_avl_add(avl, box(6), box(642), nullptr); - avl = gpr_avl_add(avl, box(680), box(643), nullptr); - avl = remove_int(avl, 741); - avl = remove_int(avl, 309); - avl = remove_int(avl, 272); - avl = gpr_avl_add(avl, box(249), box(647), nullptr); - avl = remove_int(avl, 97); - avl = remove_int(avl, 850); - avl = gpr_avl_add(avl, box(915), box(650), nullptr); - avl = gpr_avl_add(avl, box(816), box(651), nullptr); - avl = gpr_avl_add(avl, box(45), box(652), nullptr); - avl = gpr_avl_add(avl, box(168), box(653), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 239); - avl = gpr_avl_add(avl, box(684), box(656), nullptr); - avl = gpr_avl_add(avl, box(208), box(657), nullptr); - avl = gpr_avl_add(avl, box(681), box(658), nullptr); - avl = gpr_avl_add(avl, box(609), box(659), nullptr); - avl = gpr_avl_add(avl, box(645), box(660), nullptr); - avl = remove_int(avl, 799); - avl = gpr_avl_add(avl, box(955), box(662), nullptr); - avl = gpr_avl_add(avl, box(946), box(663), nullptr); - avl = gpr_avl_add(avl, box(744), box(664), nullptr); - avl = gpr_avl_add(avl, box(201), box(665), nullptr); - avl = gpr_avl_add(avl, box(136), box(666), nullptr); - avl = remove_int(avl, 357); - avl = gpr_avl_add(avl, box(974), box(668), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(1009), box(670), nullptr); - avl = gpr_avl_add(avl, box(517), box(671), nullptr); - avl = remove_int(avl, 491); - avl = gpr_avl_add(avl, box(336), box(673), nullptr); - avl = gpr_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 = gpr_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 = gpr_avl_add(avl, box(561), box(684), nullptr); - avl = gpr_avl_add(avl, box(25), box(685), nullptr); - avl = remove_int(avl, 278); - avl = gpr_avl_add(avl, box(191), box(687), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 918); - avl = remove_int(avl, 449); - avl = gpr_avl_add(avl, box(19), box(691), nullptr); - avl = gpr_avl_add(avl, box(762), box(692), nullptr); - avl = gpr_avl_add(avl, box(13), box(693), nullptr); - avl = gpr_avl_add(avl, box(151), box(694), nullptr); - avl = gpr_avl_add(avl, box(152), box(695), nullptr); - avl = gpr_avl_add(avl, box(793), box(696), nullptr); - avl = remove_int(avl, 862); - avl = remove_int(avl, 890); - avl = gpr_avl_add(avl, box(687), box(699), nullptr); - avl = gpr_avl_add(avl, box(509), box(700), nullptr); - avl = gpr_avl_add(avl, box(973), box(701), nullptr); - avl = remove_int(avl, 230); - avl = gpr_avl_add(avl, box(532), box(703), nullptr); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(281), box(705), nullptr); - avl = gpr_avl_add(avl, box(867), box(706), nullptr); - avl = gpr_avl_add(avl, box(359), box(707), nullptr); - avl = remove_int(avl, 425); - avl = gpr_avl_add(avl, box(691), box(709), nullptr); - avl = gpr_avl_add(avl, box(163), box(710), nullptr); - avl = gpr_avl_add(avl, box(502), box(711), nullptr); - avl = remove_int(avl, 674); - avl = gpr_avl_add(avl, box(697), box(713), nullptr); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(968), box(715), nullptr); - avl = gpr_avl_add(avl, box(48), box(716), nullptr); - avl = remove_int(avl, 543); - avl = gpr_avl_add(avl, box(35), box(718), nullptr); - avl = gpr_avl_add(avl, box(751), box(719), nullptr); - avl = gpr_avl_add(avl, box(478), box(720), nullptr); - avl = remove_int(avl, 797); - avl = remove_int(avl, 309); - avl = gpr_avl_add(avl, box(927), box(723), nullptr); - avl = remove_int(avl, 504); - avl = gpr_avl_add(avl, box(286), box(725), nullptr); - avl = gpr_avl_add(avl, box(413), box(726), nullptr); - avl = gpr_avl_add(avl, box(599), box(727), nullptr); - avl = remove_int(avl, 105); - avl = remove_int(avl, 605); - avl = gpr_avl_add(avl, box(632), box(730), nullptr); - avl = gpr_avl_add(avl, box(133), box(731), nullptr); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(958), box(733), nullptr); - avl = gpr_avl_add(avl, box(729), box(734), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(694), box(736), nullptr); - avl = gpr_avl_add(avl, box(505), box(737), nullptr); - avl = remove_int(avl, 63); - avl = remove_int(avl, 714); - avl = gpr_avl_add(avl, box(1002), box(740), nullptr); - avl = remove_int(avl, 211); - avl = gpr_avl_add(avl, box(765), box(742), nullptr); - avl = gpr_avl_add(avl, box(455), box(743), nullptr); - avl = remove_int(avl, 59); - avl = remove_int(avl, 224); - avl = gpr_avl_add(avl, box(586), box(746), nullptr); - avl = gpr_avl_add(avl, box(348), box(747), nullptr); - avl = remove_int(avl, 10); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(968), box(750), nullptr); - avl = gpr_avl_add(avl, box(923), box(751), nullptr); - avl = remove_int(avl, 573); - avl = remove_int(avl, 617); - avl = gpr_avl_add(avl, box(812), box(754), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(649), box(760), nullptr); - avl = gpr_avl_add(avl, box(927), box(761), nullptr); - avl = gpr_avl_add(avl, box(454), box(762), nullptr); - avl = gpr_avl_add(avl, box(217), box(763), nullptr); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(180), box(765), nullptr); - avl = gpr_avl_add(avl, box(319), box(766), nullptr); - avl = remove_int(avl, 92); - avl = gpr_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 = gpr_avl_add(avl, box(302), box(773), nullptr); - avl = remove_int(avl, 807); - avl = gpr_avl_add(avl, box(463), box(775), nullptr); - avl = gpr_avl_add(avl, box(271), box(776), nullptr); - avl = gpr_avl_add(avl, box(644), box(777), nullptr); - avl = remove_int(avl, 618); - avl = gpr_avl_add(avl, box(166), box(779), nullptr); - avl = gpr_avl_add(avl, box(538), box(780), nullptr); - avl = remove_int(avl, 606); - avl = gpr_avl_add(avl, box(425), box(782), nullptr); - avl = remove_int(avl, 725); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(155), box(785), nullptr); - avl = remove_int(avl, 889); - avl = gpr_avl_add(avl, box(653), box(787), nullptr); - avl = remove_int(avl, 386); - avl = gpr_avl_add(avl, box(142), box(789), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 603); - avl = remove_int(avl, 971); - avl = gpr_avl_add(avl, box(80), box(793), nullptr); - avl = gpr_avl_add(avl, box(61), box(794), nullptr); - avl = gpr_avl_add(avl, box(693), box(795), nullptr); - avl = gpr_avl_add(avl, box(592), box(796), nullptr); - avl = gpr_avl_add(avl, box(433), box(797), nullptr); - avl = gpr_avl_add(avl, box(973), box(798), nullptr); - avl = remove_int(avl, 901); - avl = remove_int(avl, 340); - avl = remove_int(avl, 709); - avl = gpr_avl_add(avl, box(224), box(802), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(780), box(805), nullptr); - avl = gpr_avl_add(avl, box(867), box(806), nullptr); - avl = gpr_avl_add(avl, box(756), box(807), nullptr); - avl = gpr_avl_add(avl, box(583), box(808), nullptr); - avl = gpr_avl_add(avl, box(356), box(809), nullptr); - avl = gpr_avl_add(avl, box(58), box(810), nullptr); - avl = remove_int(avl, 219); - avl = gpr_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 = gpr_avl_add(avl, box(233), box(821), nullptr); - avl = gpr_avl_add(avl, box(479), box(822), nullptr); - avl = gpr_avl_add(avl, box(323), box(823), nullptr); - avl = gpr_avl_add(avl, box(802), box(824), nullptr); - avl = remove_int(avl, 682); - avl = remove_int(avl, 705); - avl = remove_int(avl, 487); - avl = gpr_avl_add(avl, box(530), box(828), nullptr); - avl = gpr_avl_add(avl, box(232), box(829), nullptr); - avl = remove_int(avl, 627); - avl = gpr_avl_add(avl, box(396), box(831), nullptr); - avl = gpr_avl_add(avl, box(61), box(832), nullptr); - avl = gpr_avl_add(avl, box(932), box(833), nullptr); - avl = gpr_avl_add(avl, box(108), box(834), nullptr); - avl = gpr_avl_add(avl, box(524), box(835), nullptr); - avl = remove_int(avl, 390); - avl = remove_int(avl, 307); - avl = gpr_avl_add(avl, box(722), box(838), nullptr); - avl = gpr_avl_add(avl, box(907), box(839), nullptr); - avl = remove_int(avl, 286); - avl = remove_int(avl, 337); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(973), box(843), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(997), box(846), nullptr); - avl = gpr_avl_add(avl, box(689), box(847), nullptr); - avl = remove_int(avl, 318); - avl = gpr_avl_add(avl, box(703), box(849), nullptr); - avl = gpr_avl_add(avl, box(868), box(850), nullptr); - avl = gpr_avl_add(avl, box(200), box(851), nullptr); - avl = gpr_avl_add(avl, box(960), box(852), nullptr); - avl = gpr_avl_add(avl, box(80), box(853), nullptr); - avl = remove_int(avl, 113); - avl = gpr_avl_add(avl, box(135), box(855), nullptr); - avl = remove_int(avl, 529); - avl = gpr_avl_add(avl, box(366), box(857), nullptr); - avl = remove_int(avl, 272); - avl = gpr_avl_add(avl, box(921), box(859), nullptr); - avl = remove_int(avl, 497); - avl = gpr_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 = gpr_avl_add(avl, box(388), box(866), nullptr); - avl = gpr_avl_add(avl, box(29), box(867), nullptr); - avl = gpr_avl_add(avl, box(180), box(868), nullptr); - avl = gpr_avl_add(avl, box(983), box(869), nullptr); - avl = gpr_avl_add(avl, box(72), box(870), nullptr); - avl = gpr_avl_add(avl, box(693), box(871), nullptr); - avl = gpr_avl_add(avl, box(567), box(872), nullptr); - avl = remove_int(avl, 549); - avl = remove_int(avl, 351); - avl = gpr_avl_add(avl, box(1019), box(875), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 294); - avl = remove_int(avl, 61); - avl = gpr_avl_add(avl, box(409), box(879), nullptr); - avl = gpr_avl_add(avl, box(984), box(880), nullptr); - avl = gpr_avl_add(avl, box(830), box(881), nullptr); - avl = remove_int(avl, 579); - avl = gpr_avl_add(avl, box(672), box(883), nullptr); - avl = remove_int(avl, 968); - - gpr_avl_unref(avl, nullptr); -} - -static void test_badcase3(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase3"); - - avl = gpr_avl_create(&int_int_vtable); - avl = remove_int(avl, 624); - avl = gpr_avl_add(avl, box(59), box(2), nullptr); - avl = gpr_avl_add(avl, box(494), box(3), nullptr); - avl = gpr_avl_add(avl, box(226), box(4), nullptr); - avl = remove_int(avl, 524); - avl = gpr_avl_add(avl, box(540), box(6), nullptr); - avl = remove_int(avl, 1008); - avl = gpr_avl_add(avl, box(502), box(8), nullptr); - avl = remove_int(avl, 267); - avl = remove_int(avl, 764); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(8), box(12), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 796); - avl = remove_int(avl, 1002); - avl = gpr_avl_add(avl, box(778), box(16), nullptr); - avl = remove_int(avl, 621); - avl = remove_int(avl, 891); - avl = remove_int(avl, 880); - avl = gpr_avl_add(avl, box(197), box(20), nullptr); - avl = gpr_avl_add(avl, box(441), box(21), nullptr); - avl = gpr_avl_add(avl, box(719), box(22), nullptr); - avl = remove_int(avl, 109); - avl = gpr_avl_add(avl, box(458), box(24), nullptr); - avl = remove_int(avl, 86); - avl = gpr_avl_add(avl, box(897), box(26), nullptr); - avl = gpr_avl_add(avl, box(997), box(27), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 425); - avl = remove_int(avl, 186); - avl = gpr_avl_add(avl, box(887), box(31), nullptr); - avl = gpr_avl_add(avl, box(1005), box(32), nullptr); - avl = gpr_avl_add(avl, box(778), box(33), nullptr); - avl = gpr_avl_add(avl, box(575), box(34), nullptr); - avl = remove_int(avl, 966); - avl = remove_int(avl, 1015); - avl = gpr_avl_add(avl, box(486), box(37), nullptr); - avl = gpr_avl_add(avl, box(809), box(38), nullptr); - avl = gpr_avl_add(avl, box(907), box(39), nullptr); - avl = gpr_avl_add(avl, box(971), box(40), nullptr); - avl = remove_int(avl, 441); - avl = remove_int(avl, 498); - avl = gpr_avl_add(avl, box(727), box(43), nullptr); - avl = remove_int(avl, 679); - avl = remove_int(avl, 740); - avl = remove_int(avl, 532); - avl = gpr_avl_add(avl, box(805), box(47), nullptr); - avl = remove_int(avl, 64); - avl = gpr_avl_add(avl, box(362), box(49), nullptr); - avl = gpr_avl_add(avl, box(170), box(50), nullptr); - avl = gpr_avl_add(avl, box(389), box(51), nullptr); - avl = gpr_avl_add(avl, box(689), box(52), nullptr); - avl = remove_int(avl, 871); - avl = gpr_avl_add(avl, box(447), box(54), nullptr); - avl = remove_int(avl, 718); - avl = gpr_avl_add(avl, box(724), box(56), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(550), box(58), nullptr); - avl = remove_int(avl, 932); - avl = gpr_avl_add(avl, box(47), box(60), nullptr); - avl = remove_int(avl, 46); - avl = remove_int(avl, 229); - avl = gpr_avl_add(avl, box(68), box(63), nullptr); - avl = gpr_avl_add(avl, box(387), box(64), nullptr); - avl = remove_int(avl, 933); - avl = remove_int(avl, 736); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(150), box(68), nullptr); - avl = remove_int(avl, 875); - avl = remove_int(avl, 298); - avl = gpr_avl_add(avl, box(991), box(71), nullptr); - avl = remove_int(avl, 705); - avl = gpr_avl_add(avl, box(197), box(73), nullptr); - avl = gpr_avl_add(avl, box(101), box(74), nullptr); - avl = remove_int(avl, 436); - avl = gpr_avl_add(avl, box(755), box(76), nullptr); - avl = gpr_avl_add(avl, box(727), box(77), nullptr); - avl = remove_int(avl, 309); - avl = remove_int(avl, 253); - avl = gpr_avl_add(avl, box(203), box(80), nullptr); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(461), box(82), nullptr); - avl = remove_int(avl, 316); - avl = remove_int(avl, 493); - avl = gpr_avl_add(avl, box(184), box(85), nullptr); - avl = remove_int(avl, 737); - avl = gpr_avl_add(avl, box(790), box(87), nullptr); - avl = gpr_avl_add(avl, box(335), box(88), nullptr); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(69), box(90), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 543); - avl = gpr_avl_add(avl, box(784), box(93), nullptr); - avl = gpr_avl_add(avl, box(60), box(94), nullptr); - avl = gpr_avl_add(avl, box(525), box(95), nullptr); - avl = gpr_avl_add(avl, box(177), box(96), nullptr); - avl = gpr_avl_add(avl, box(178), box(97), nullptr); - avl = gpr_avl_add(avl, box(683), box(98), nullptr); - avl = gpr_avl_add(avl, box(226), box(99), nullptr); - avl = gpr_avl_add(avl, box(662), box(100), nullptr); - avl = remove_int(avl, 944); - avl = gpr_avl_add(avl, box(562), box(102), nullptr); - avl = gpr_avl_add(avl, box(793), box(103), nullptr); - avl = remove_int(avl, 673); - avl = gpr_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 = gpr_avl_add(avl, box(318), box(110), nullptr); - avl = gpr_avl_add(avl, box(483), box(111), nullptr); - avl = gpr_avl_add(avl, box(84), box(112), nullptr); - avl = remove_int(avl, 109); - avl = gpr_avl_add(avl, box(132), box(114), nullptr); - avl = gpr_avl_add(avl, box(920), box(115), nullptr); - avl = remove_int(avl, 746); - avl = gpr_avl_add(avl, box(145), box(117), nullptr); - avl = gpr_avl_add(avl, box(526), box(118), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(332), box(120), nullptr); - avl = gpr_avl_add(avl, box(918), box(121), nullptr); - avl = remove_int(avl, 339); - avl = gpr_avl_add(avl, box(809), box(123), nullptr); - avl = gpr_avl_add(avl, box(742), box(124), nullptr); - avl = gpr_avl_add(avl, box(718), box(125), nullptr); - avl = remove_int(avl, 988); - avl = remove_int(avl, 531); - avl = remove_int(avl, 840); - avl = gpr_avl_add(avl, box(816), box(129), nullptr); - avl = gpr_avl_add(avl, box(976), box(130), nullptr); - avl = remove_int(avl, 743); - avl = remove_int(avl, 528); - avl = remove_int(avl, 982); - avl = gpr_avl_add(avl, box(803), box(134), nullptr); - avl = gpr_avl_add(avl, box(205), box(135), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(270), box(142), nullptr); - avl = gpr_avl_add(avl, box(333), box(143), nullptr); - avl = remove_int(avl, 439); - avl = gpr_avl_add(avl, box(35), box(145), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(624), box(153), nullptr); - avl = gpr_avl_add(avl, box(116), box(154), nullptr); - avl = gpr_avl_add(avl, box(446), box(155), nullptr); - avl = remove_int(avl, 91); - avl = remove_int(avl, 721); - avl = remove_int(avl, 537); - avl = gpr_avl_add(avl, box(448), box(159), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 344); - avl = remove_int(avl, 237); - avl = gpr_avl_add(avl, box(309), box(163), nullptr); - avl = gpr_avl_add(avl, box(434), box(164), nullptr); - avl = gpr_avl_add(avl, box(277), box(165), nullptr); - avl = remove_int(avl, 233); - avl = gpr_avl_add(avl, box(275), box(167), nullptr); - avl = gpr_avl_add(avl, box(218), box(168), nullptr); - avl = gpr_avl_add(avl, box(76), box(169), nullptr); - avl = gpr_avl_add(avl, box(898), box(170), nullptr); - avl = remove_int(avl, 771); - avl = gpr_avl_add(avl, box(237), box(172), nullptr); - avl = remove_int(avl, 327); - avl = gpr_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 = gpr_avl_add(avl, box(442), box(181), nullptr); - avl = remove_int(avl, 389); - avl = gpr_avl_add(avl, box(708), box(183), nullptr); - avl = gpr_avl_add(avl, box(594), box(184), nullptr); - avl = gpr_avl_add(avl, box(942), box(185), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(99), box(196), nullptr); - avl = gpr_avl_add(avl, box(161), box(197), nullptr); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(72), box(199), nullptr); - avl = remove_int(avl, 629); - avl = gpr_avl_add(avl, box(522), box(201), nullptr); - avl = remove_int(avl, 679); - avl = gpr_avl_add(avl, box(407), box(203), nullptr); - avl = remove_int(avl, 693); - avl = gpr_avl_add(avl, box(424), box(205), nullptr); - avl = gpr_avl_add(avl, box(651), box(206), nullptr); - avl = gpr_avl_add(avl, box(927), box(207), nullptr); - avl = remove_int(avl, 553); - avl = gpr_avl_add(avl, box(128), box(209), nullptr); - avl = gpr_avl_add(avl, box(616), box(210), nullptr); - avl = gpr_avl_add(avl, box(690), box(211), nullptr); - avl = remove_int(avl, 241); - avl = remove_int(avl, 179); - avl = gpr_avl_add(avl, box(697), box(214), nullptr); - avl = remove_int(avl, 779); - avl = gpr_avl_add(avl, box(241), box(216), nullptr); - avl = remove_int(avl, 190); - avl = remove_int(avl, 210); - avl = gpr_avl_add(avl, box(711), box(219), nullptr); - avl = remove_int(avl, 251); - avl = remove_int(avl, 61); - avl = gpr_avl_add(avl, box(800), box(222), nullptr); - avl = remove_int(avl, 551); - avl = gpr_avl_add(avl, box(61), box(224), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(799), box(230), nullptr); - avl = gpr_avl_add(avl, box(125), box(231), nullptr); - avl = remove_int(avl, 107); - avl = gpr_avl_add(avl, box(938), box(233), nullptr); - avl = gpr_avl_add(avl, box(914), box(234), nullptr); - avl = gpr_avl_add(avl, box(197), box(235), nullptr); - avl = remove_int(avl, 736); - avl = gpr_avl_add(avl, box(20), box(237), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 841); - avl = gpr_avl_add(avl, box(226), box(240), nullptr); - avl = remove_int(avl, 963); - avl = remove_int(avl, 796); - avl = remove_int(avl, 728); - avl = gpr_avl_add(avl, box(855), box(244), nullptr); - avl = gpr_avl_add(avl, box(769), box(245), nullptr); - avl = gpr_avl_add(avl, box(631), box(246), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(187), box(248), nullptr); - avl = gpr_avl_add(avl, box(31), box(249), nullptr); - avl = remove_int(avl, 163); - avl = gpr_avl_add(avl, box(218), box(251), nullptr); - avl = gpr_avl_add(avl, box(488), box(252), nullptr); - avl = gpr_avl_add(avl, box(387), box(253), nullptr); - avl = gpr_avl_add(avl, box(809), box(254), nullptr); - avl = gpr_avl_add(avl, box(997), box(255), nullptr); - avl = remove_int(avl, 678); - avl = gpr_avl_add(avl, box(368), box(257), nullptr); - avl = gpr_avl_add(avl, box(220), box(258), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(868), box(264), nullptr); - avl = remove_int(avl, 254); - avl = remove_int(avl, 456); - avl = gpr_avl_add(avl, box(906), box(267), nullptr); - avl = remove_int(avl, 711); - avl = gpr_avl_add(avl, box(632), box(269), nullptr); - avl = remove_int(avl, 474); - avl = gpr_avl_add(avl, box(508), box(271), nullptr); - avl = gpr_avl_add(avl, box(518), box(272), nullptr); - avl = remove_int(avl, 579); - avl = remove_int(avl, 948); - avl = gpr_avl_add(avl, box(789), box(275), nullptr); - avl = gpr_avl_add(avl, box(48), box(276), nullptr); - avl = gpr_avl_add(avl, box(256), box(277), nullptr); - avl = gpr_avl_add(avl, box(754), box(278), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(679), box(280), nullptr); - avl = gpr_avl_add(avl, box(606), box(281), nullptr); - avl = remove_int(avl, 941); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(758), box(284), nullptr); - avl = remove_int(avl, 101); - avl = gpr_avl_add(avl, box(244), box(286), nullptr); - avl = gpr_avl_add(avl, box(337), box(287), nullptr); - avl = gpr_avl_add(avl, box(461), box(288), nullptr); - avl = remove_int(avl, 476); - avl = gpr_avl_add(avl, box(845), box(290), nullptr); - avl = remove_int(avl, 160); - avl = gpr_avl_add(avl, box(690), box(292), nullptr); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(869), box(294), nullptr); - avl = gpr_avl_add(avl, box(1019), box(295), nullptr); - avl = remove_int(avl, 591); - avl = remove_int(avl, 635); - avl = remove_int(avl, 67); - avl = gpr_avl_add(avl, box(113), box(299), nullptr); - avl = remove_int(avl, 305); - avl = gpr_avl_add(avl, box(10), box(301), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 288); - avl = remove_int(avl, 239); - avl = gpr_avl_add(avl, box(646), box(305), nullptr); - avl = gpr_avl_add(avl, box(1006), box(306), nullptr); - avl = gpr_avl_add(avl, box(954), box(307), nullptr); - avl = gpr_avl_add(avl, box(199), box(308), nullptr); - avl = gpr_avl_add(avl, box(69), box(309), nullptr); - avl = gpr_avl_add(avl, box(984), box(310), nullptr); - avl = remove_int(avl, 568); - avl = remove_int(avl, 666); - avl = remove_int(avl, 37); - avl = gpr_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 = gpr_avl_add(avl, box(853), box(322), nullptr); - avl = gpr_avl_add(avl, box(335), box(323), nullptr); - avl = gpr_avl_add(avl, box(961), box(324), nullptr); - avl = gpr_avl_add(avl, box(73), box(325), nullptr); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(449), box(327), nullptr); - avl = remove_int(avl, 821); - avl = gpr_avl_add(avl, box(845), box(329), nullptr); - avl = remove_int(avl, 637); - avl = gpr_avl_add(avl, box(769), box(331), nullptr); - avl = gpr_avl_add(avl, box(901), box(332), nullptr); - avl = remove_int(avl, 142); - avl = remove_int(avl, 361); - avl = remove_int(avl, 876); - avl = gpr_avl_add(avl, box(614), box(336), nullptr); - avl = gpr_avl_add(avl, box(729), box(337), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 473); - avl = remove_int(avl, 445); - avl = gpr_avl_add(avl, box(978), box(341), nullptr); - avl = gpr_avl_add(avl, box(164), box(342), nullptr); - avl = gpr_avl_add(avl, box(1), box(343), nullptr); - avl = remove_int(avl, 890); - avl = gpr_avl_add(avl, box(605), box(345), nullptr); - avl = gpr_avl_add(avl, box(178), box(346), nullptr); - avl = gpr_avl_add(avl, box(481), box(347), nullptr); - avl = gpr_avl_add(avl, box(772), box(348), nullptr); - avl = remove_int(avl, 824); - avl = remove_int(avl, 167); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(698), box(352), nullptr); - avl = gpr_avl_add(avl, box(202), box(353), nullptr); - avl = gpr_avl_add(avl, box(921), box(354), nullptr); - avl = gpr_avl_add(avl, box(875), box(355), nullptr); - avl = remove_int(avl, 197); - avl = remove_int(avl, 232); - avl = gpr_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 = gpr_avl_add(avl, box(661), box(364), nullptr); - avl = gpr_avl_add(avl, box(113), box(365), nullptr); - avl = remove_int(avl, 767); - avl = gpr_avl_add(avl, box(586), box(367), nullptr); - avl = gpr_avl_add(avl, box(121), box(368), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 439); - avl = remove_int(avl, 360); - avl = gpr_avl_add(avl, box(916), box(372), nullptr); - avl = remove_int(avl, 999); - avl = gpr_avl_add(avl, box(825), box(374), nullptr); - avl = gpr_avl_add(avl, box(177), box(375), nullptr); - avl = remove_int(avl, 204); - avl = remove_int(avl, 92); - avl = gpr_avl_add(avl, box(794), box(378), nullptr); - avl = gpr_avl_add(avl, box(463), box(379), nullptr); - avl = gpr_avl_add(avl, box(472), box(380), nullptr); - avl = remove_int(avl, 235); - avl = gpr_avl_add(avl, box(840), box(382), nullptr); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(586), box(384), nullptr); - avl = gpr_avl_add(avl, box(979), box(385), nullptr); - avl = remove_int(avl, 979); - avl = gpr_avl_add(avl, box(639), box(387), nullptr); - avl = remove_int(avl, 907); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(913), box(390), nullptr); - avl = gpr_avl_add(avl, box(566), box(391), nullptr); - avl = gpr_avl_add(avl, box(883), box(392), nullptr); - avl = gpr_avl_add(avl, box(552), box(393), nullptr); - avl = gpr_avl_add(avl, box(16), box(394), nullptr); - avl = remove_int(avl, 60); - avl = gpr_avl_add(avl, box(567), box(396), nullptr); - avl = gpr_avl_add(avl, box(705), box(397), nullptr); - avl = gpr_avl_add(avl, box(94), box(398), nullptr); - avl = remove_int(avl, 321); - avl = gpr_avl_add(avl, box(207), box(400), nullptr); - avl = gpr_avl_add(avl, box(682), box(401), nullptr); - avl = gpr_avl_add(avl, box(592), box(402), nullptr); - avl = gpr_avl_add(avl, box(10), box(403), nullptr); - avl = remove_int(avl, 911); - avl = remove_int(avl, 161); - avl = gpr_avl_add(avl, box(86), box(406), nullptr); - avl = remove_int(avl, 893); - avl = remove_int(avl, 362); - avl = gpr_avl_add(avl, box(599), box(409), nullptr); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(867), box(411), nullptr); - avl = remove_int(avl, 955); - avl = gpr_avl_add(avl, box(341), box(413), nullptr); - avl = gpr_avl_add(avl, box(887), box(414), nullptr); - avl = remove_int(avl, 706); - avl = gpr_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 = gpr_avl_add(avl, box(326), box(421), nullptr); - avl = remove_int(avl, 848); - avl = gpr_avl_add(avl, box(235), box(423), nullptr); - avl = remove_int(avl, 617); - avl = gpr_avl_add(avl, box(565), box(425), nullptr); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(988), box(427), nullptr); - avl = remove_int(avl, 957); - avl = gpr_avl_add(avl, box(426), box(429), nullptr); - avl = remove_int(avl, 967); - avl = gpr_avl_add(avl, box(890), box(431), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(459), box(439), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 782); - avl = gpr_avl_add(avl, box(408), box(442), nullptr); - avl = gpr_avl_add(avl, box(728), box(443), nullptr); - avl = remove_int(avl, 27); - avl = gpr_avl_add(avl, box(137), box(445), nullptr); - avl = gpr_avl_add(avl, box(239), box(446), nullptr); - avl = remove_int(avl, 854); - avl = gpr_avl_add(avl, box(104), box(448), nullptr); - avl = gpr_avl_add(avl, box(823), box(449), nullptr); - avl = gpr_avl_add(avl, box(524), box(450), nullptr); - avl = gpr_avl_add(avl, box(995), box(451), nullptr); - avl = remove_int(avl, 422); - avl = remove_int(avl, 220); - avl = gpr_avl_add(avl, box(856), box(454), nullptr); - avl = remove_int(avl, 332); - avl = gpr_avl_add(avl, box(679), box(456), nullptr); - avl = remove_int(avl, 18); - avl = gpr_avl_add(avl, box(837), box(458), nullptr); - avl = remove_int(avl, 405); - avl = remove_int(avl, 877); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(547), box(462), nullptr); - avl = remove_int(avl, 805); - avl = remove_int(avl, 862); - avl = gpr_avl_add(avl, box(75), box(465), nullptr); - avl = remove_int(avl, 41); - avl = gpr_avl_add(avl, box(310), box(467), nullptr); - avl = remove_int(avl, 855); - avl = gpr_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 = gpr_avl_add(avl, box(118), box(474), nullptr); - avl = gpr_avl_add(avl, box(96), box(475), nullptr); - avl = remove_int(avl, 854); - avl = gpr_avl_add(avl, box(65), box(477), nullptr); - avl = gpr_avl_add(avl, box(573), box(478), nullptr); - avl = gpr_avl_add(avl, box(4), box(479), nullptr); - avl = gpr_avl_add(avl, box(451), box(480), nullptr); - avl = gpr_avl_add(avl, box(774), box(481), nullptr); - avl = gpr_avl_add(avl, box(126), box(482), nullptr); - avl = remove_int(avl, 956); - avl = remove_int(avl, 591); - avl = remove_int(avl, 644); - avl = gpr_avl_add(avl, box(304), box(486), nullptr); - avl = remove_int(avl, 620); - avl = remove_int(avl, 394); - avl = gpr_avl_add(avl, box(1002), box(489), nullptr); - avl = gpr_avl_add(avl, box(837), box(490), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(1005), box(492), nullptr); - avl = remove_int(avl, 21); - avl = gpr_avl_add(avl, box(396), box(494), nullptr); - avl = remove_int(avl, 966); - avl = gpr_avl_add(avl, box(105), box(496), nullptr); - avl = gpr_avl_add(avl, box(316), box(497), nullptr); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(188), box(499), nullptr); - avl = remove_int(avl, 200); - avl = gpr_avl_add(avl, box(98), box(501), nullptr); - avl = gpr_avl_add(avl, box(831), box(502), nullptr); - avl = gpr_avl_add(avl, box(227), box(503), nullptr); - avl = gpr_avl_add(avl, box(220), box(504), nullptr); - avl = remove_int(avl, 715); - avl = remove_int(avl, 279); - avl = gpr_avl_add(avl, box(701), box(507), nullptr); - avl = gpr_avl_add(avl, box(726), box(508), nullptr); - avl = gpr_avl_add(avl, box(815), box(509), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(545), box(515), nullptr); - avl = remove_int(avl, 59); - avl = gpr_avl_add(avl, box(168), box(517), nullptr); - avl = remove_int(avl, 337); - avl = gpr_avl_add(avl, box(69), box(519), nullptr); - avl = remove_int(avl, 600); - avl = gpr_avl_add(avl, box(591), box(521), nullptr); - avl = gpr_avl_add(avl, box(960), box(522), nullptr); - avl = gpr_avl_add(avl, box(116), box(523), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(760), box(525), nullptr); - avl = gpr_avl_add(avl, box(664), box(526), nullptr); - avl = gpr_avl_add(avl, box(547), box(527), nullptr); - avl = remove_int(avl, 922); - avl = gpr_avl_add(avl, box(290), box(529), nullptr); - avl = gpr_avl_add(avl, box(859), box(530), nullptr); - avl = gpr_avl_add(avl, box(49), box(531), nullptr); - avl = remove_int(avl, 455); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(613), box(534), nullptr); - avl = gpr_avl_add(avl, box(326), box(535), nullptr); - avl = remove_int(avl, 615); - avl = gpr_avl_add(avl, box(45), box(537), nullptr); - avl = gpr_avl_add(avl, box(162), box(538), nullptr); - avl = gpr_avl_add(avl, box(189), box(539), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(608), box(542), nullptr); - avl = remove_int(avl, 821); - avl = gpr_avl_add(avl, box(978), box(544), nullptr); - avl = gpr_avl_add(avl, box(892), box(545), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(708), box(547), nullptr); - avl = remove_int(avl, 135); - avl = remove_int(avl, 124); - avl = gpr_avl_add(avl, box(301), box(550), nullptr); - avl = gpr_avl_add(avl, box(939), box(551), nullptr); - avl = gpr_avl_add(avl, box(344), box(552), nullptr); - avl = remove_int(avl, 443); - avl = remove_int(avl, 122); - avl = gpr_avl_add(avl, box(636), box(555), nullptr); - avl = remove_int(avl, 558); - avl = gpr_avl_add(avl, box(923), box(557), nullptr); - avl = remove_int(avl, 827); - avl = gpr_avl_add(avl, box(649), box(559), nullptr); - avl = gpr_avl_add(avl, box(808), box(560), nullptr); - avl = remove_int(avl, 570); - avl = remove_int(avl, 434); - avl = gpr_avl_add(avl, box(40), box(563), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(483), box(571), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(898), box(578), nullptr); - avl = remove_int(avl, 770); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(602), box(581), nullptr); - avl = remove_int(avl, 251); - avl = gpr_avl_add(avl, box(303), box(583), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(714), box(585), nullptr); - avl = remove_int(avl, 800); - avl = gpr_avl_add(avl, box(266), box(587), nullptr); - avl = gpr_avl_add(avl, box(555), box(588), nullptr); - avl = remove_int(avl, 604); - avl = remove_int(avl, 163); - avl = remove_int(avl, 497); - avl = gpr_avl_add(avl, box(296), box(592), nullptr); - avl = remove_int(avl, 129); - avl = gpr_avl_add(avl, box(656), box(594), nullptr); - avl = remove_int(avl, 769); - avl = remove_int(avl, 941); - avl = gpr_avl_add(avl, box(775), box(597), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(866), box(603), nullptr); - avl = gpr_avl_add(avl, box(575), box(604), nullptr); - avl = gpr_avl_add(avl, box(620), box(605), nullptr); - avl = remove_int(avl, 100); - avl = remove_int(avl, 667); - avl = gpr_avl_add(avl, box(138), box(608), nullptr); - avl = gpr_avl_add(avl, box(566), box(609), nullptr); - avl = gpr_avl_add(avl, box(673), box(610), nullptr); - avl = gpr_avl_add(avl, box(178), box(611), nullptr); - avl = remove_int(avl, 659); - avl = gpr_avl_add(avl, box(759), box(613), nullptr); - avl = gpr_avl_add(avl, box(1008), box(614), nullptr); - avl = remove_int(avl, 116); - avl = gpr_avl_add(avl, box(608), box(616), nullptr); - avl = gpr_avl_add(avl, box(339), box(617), nullptr); - avl = gpr_avl_add(avl, box(197), box(618), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 628); - avl = gpr_avl_add(avl, box(487), box(621), nullptr); - avl = remove_int(avl, 739); - avl = remove_int(avl, 100); - avl = remove_int(avl, 928); - avl = gpr_avl_add(avl, box(647), box(625), nullptr); - avl = remove_int(avl, 978); - avl = remove_int(avl, 143); - avl = remove_int(avl, 755); - avl = gpr_avl_add(avl, box(71), box(629), nullptr); - avl = remove_int(avl, 205); - avl = gpr_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 = gpr_avl_add(avl, box(330), box(637), nullptr); - avl = remove_int(avl, 264); - avl = gpr_avl_add(avl, box(69), box(639), nullptr); - avl = remove_int(avl, 73); - avl = gpr_avl_add(avl, box(745), box(641), nullptr); - avl = remove_int(avl, 518); - avl = remove_int(avl, 641); - avl = remove_int(avl, 768); - avl = gpr_avl_add(avl, box(988), box(645), nullptr); - avl = gpr_avl_add(avl, box(899), box(646), nullptr); - avl = remove_int(avl, 763); - avl = remove_int(avl, 281); - avl = remove_int(avl, 496); - avl = gpr_avl_add(avl, box(445), box(650), nullptr); - avl = remove_int(avl, 905); - avl = gpr_avl_add(avl, box(275), box(652), nullptr); - avl = gpr_avl_add(avl, box(137), box(653), nullptr); - avl = remove_int(avl, 642); - avl = gpr_avl_add(avl, box(708), box(655), nullptr); - avl = remove_int(avl, 922); - avl = gpr_avl_add(avl, box(743), box(657), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 665); - avl = remove_int(avl, 48); - avl = gpr_avl_add(avl, box(1012), box(661), nullptr); - avl = remove_int(avl, 71); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(319), box(664), nullptr); - avl = remove_int(avl, 632); - avl = gpr_avl_add(avl, box(137), box(666), nullptr); - avl = gpr_avl_add(avl, box(686), box(667), nullptr); - avl = gpr_avl_add(avl, box(724), box(668), nullptr); - avl = gpr_avl_add(avl, box(952), box(669), nullptr); - avl = gpr_avl_add(avl, box(5), box(670), nullptr); - avl = remove_int(avl, 35); - avl = gpr_avl_add(avl, box(43), box(672), nullptr); - avl = gpr_avl_add(avl, box(320), box(673), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(1016), box(679), nullptr); - avl = gpr_avl_add(avl, box(605), box(680), nullptr); - avl = gpr_avl_add(avl, box(152), box(681), nullptr); - avl = gpr_avl_add(avl, box(113), box(682), nullptr); - avl = remove_int(avl, 131); - avl = remove_int(avl, 637); - avl = gpr_avl_add(avl, box(156), box(685), nullptr); - avl = remove_int(avl, 696); - avl = gpr_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 = gpr_avl_add(avl, box(500), box(701), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(825), box(703), nullptr); - avl = remove_int(avl, 888); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(285), box(706), nullptr); - avl = remove_int(avl, 62); - avl = remove_int(avl, 444); - avl = remove_int(avl, 946); - avl = gpr_avl_add(avl, box(122), box(710), nullptr); - avl = gpr_avl_add(avl, box(846), box(711), nullptr); - avl = remove_int(avl, 628); - avl = gpr_avl_add(avl, box(511), box(713), nullptr); - avl = gpr_avl_add(avl, box(398), box(714), nullptr); - avl = remove_int(avl, 730); - avl = gpr_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 = gpr_avl_add(avl, box(346), box(725), nullptr); - avl = gpr_avl_add(avl, box(1015), box(726), nullptr); - avl = remove_int(avl, 813); - avl = gpr_avl_add(avl, box(213), box(728), nullptr); - avl = remove_int(avl, 468); - avl = remove_int(avl, 365); - avl = remove_int(avl, 399); - avl = gpr_avl_add(avl, box(380), box(732), nullptr); - avl = remove_int(avl, 835); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(700), box(735), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(587), box(743), nullptr); - avl = gpr_avl_add(avl, box(332), box(744), nullptr); - avl = remove_int(avl, 686); - avl = remove_int(avl, 206); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(334), box(748), nullptr); - avl = remove_int(avl, 171); - avl = gpr_avl_add(avl, box(1002), box(750), nullptr); - avl = gpr_avl_add(avl, box(779), box(751), nullptr); - avl = gpr_avl_add(avl, box(307), box(752), nullptr); - avl = gpr_avl_add(avl, box(127), box(753), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(812), box(760), nullptr); - avl = remove_int(avl, 43); - avl = gpr_avl_add(avl, box(871), box(762), nullptr); - avl = gpr_avl_add(avl, box(580), box(763), nullptr); - avl = remove_int(avl, 501); - avl = remove_int(avl, 462); - avl = remove_int(avl, 599); - avl = gpr_avl_add(avl, box(240), box(767), nullptr); - avl = gpr_avl_add(avl, box(285), box(768), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(495), box(777), nullptr); - avl = gpr_avl_add(avl, box(552), box(778), nullptr); - avl = remove_int(avl, 19); - avl = remove_int(avl, 803); - avl = gpr_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 = gpr_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 = gpr_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 = gpr_avl_add(avl, box(578), box(796), nullptr); - avl = remove_int(avl, 38); - avl = remove_int(avl, 595); - avl = gpr_avl_add(avl, box(213), box(799), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 620); - avl = gpr_avl_add(avl, box(946), box(802), nullptr); - avl = remove_int(avl, 145); - avl = gpr_avl_add(avl, box(628), box(804), nullptr); - avl = remove_int(avl, 972); - avl = gpr_avl_add(avl, box(728), box(806), nullptr); - avl = remove_int(avl, 91); - avl = gpr_avl_add(avl, box(136), box(808), nullptr); - avl = gpr_avl_add(avl, box(841), box(809), nullptr); - avl = gpr_avl_add(avl, box(265), box(810), nullptr); - avl = gpr_avl_add(avl, box(701), box(811), nullptr); - avl = gpr_avl_add(avl, box(27), box(812), nullptr); - avl = remove_int(avl, 72); - avl = remove_int(avl, 14); - avl = gpr_avl_add(avl, box(286), box(815), nullptr); - avl = remove_int(avl, 996); - avl = remove_int(avl, 998); - avl = gpr_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 = gpr_avl_add(avl, box(267), box(827), nullptr); - avl = remove_int(avl, 812); - avl = gpr_avl_add(avl, box(577), box(829), nullptr); - avl = remove_int(avl, 624); - avl = remove_int(avl, 847); - avl = remove_int(avl, 745); - avl = gpr_avl_add(avl, box(491), box(833), nullptr); - avl = gpr_avl_add(avl, box(941), box(834), nullptr); - avl = remove_int(avl, 258); - avl = gpr_avl_add(avl, box(410), box(836), nullptr); - avl = gpr_avl_add(avl, box(80), box(837), nullptr); - avl = gpr_avl_add(avl, box(196), box(838), nullptr); - avl = gpr_avl_add(avl, box(5), box(839), nullptr); - avl = remove_int(avl, 782); - avl = gpr_avl_add(avl, box(827), box(841), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 664); - avl = gpr_avl_add(avl, box(409), box(844), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(405), box(852), nullptr); - avl = remove_int(avl, 587); - avl = remove_int(avl, 350); - avl = gpr_avl_add(avl, box(980), box(855), nullptr); - avl = gpr_avl_add(avl, box(992), box(856), nullptr); - avl = gpr_avl_add(avl, box(818), box(857), nullptr); - avl = remove_int(avl, 853); - avl = remove_int(avl, 701); - avl = gpr_avl_add(avl, box(675), box(860), nullptr); - avl = remove_int(avl, 248); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(508), box(863), nullptr); - avl = remove_int(avl, 927); - avl = gpr_avl_add(avl, box(957), box(865), nullptr); - avl = gpr_avl_add(avl, box(698), box(866), nullptr); - avl = gpr_avl_add(avl, box(388), box(867), nullptr); - avl = gpr_avl_add(avl, box(532), box(868), nullptr); - avl = gpr_avl_add(avl, box(681), box(869), nullptr); - avl = remove_int(avl, 544); - avl = remove_int(avl, 991); - avl = remove_int(avl, 397); - avl = gpr_avl_add(avl, box(954), box(873), nullptr); - avl = gpr_avl_add(avl, box(219), box(874), nullptr); - avl = gpr_avl_add(avl, box(465), box(875), nullptr); - avl = remove_int(avl, 371); - avl = gpr_avl_add(avl, box(601), box(877), nullptr); - avl = gpr_avl_add(avl, box(543), box(878), nullptr); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(560), box(880), nullptr); - avl = remove_int(avl, 898); - avl = gpr_avl_add(avl, box(455), box(882), nullptr); - avl = remove_int(avl, 313); - avl = gpr_avl_add(avl, box(215), box(884), nullptr); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(608), box(886), nullptr); - avl = remove_int(avl, 248); - avl = gpr_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 = gpr_avl_add(avl, box(154), box(893), nullptr); - avl = gpr_avl_add(avl, box(329), box(894), nullptr); - avl = gpr_avl_add(avl, box(326), box(895), nullptr); - avl = remove_int(avl, 746); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(464), box(898), nullptr); - avl = gpr_avl_add(avl, box(141), box(899), nullptr); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(414), box(901), nullptr); - avl = gpr_avl_add(avl, box(777), box(902), nullptr); - avl = remove_int(avl, 972); - avl = remove_int(avl, 841); - avl = remove_int(avl, 100); - avl = gpr_avl_add(avl, box(828), box(906), nullptr); - avl = remove_int(avl, 785); - avl = gpr_avl_add(avl, box(1008), box(908), nullptr); - avl = gpr_avl_add(avl, box(46), box(909), nullptr); - avl = remove_int(avl, 399); - avl = gpr_avl_add(avl, box(178), box(911), nullptr); - avl = gpr_avl_add(avl, box(573), box(912), nullptr); - avl = remove_int(avl, 299); - avl = gpr_avl_add(avl, box(690), box(914), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(167), box(921), nullptr); - avl = remove_int(avl, 328); - avl = gpr_avl_add(avl, box(89), box(923), nullptr); - avl = remove_int(avl, 867); - avl = remove_int(avl, 626); - avl = remove_int(avl, 507); - avl = gpr_avl_add(avl, box(365), box(927), nullptr); - avl = gpr_avl_add(avl, box(58), box(928), nullptr); - avl = gpr_avl_add(avl, box(70), box(929), nullptr); - avl = remove_int(avl, 81); - avl = remove_int(avl, 797); - avl = gpr_avl_add(avl, box(846), box(932), nullptr); - avl = remove_int(avl, 642); - avl = gpr_avl_add(avl, box(777), box(934), nullptr); - avl = remove_int(avl, 107); - avl = gpr_avl_add(avl, box(691), box(936), nullptr); - avl = gpr_avl_add(avl, box(820), box(937), nullptr); - avl = gpr_avl_add(avl, box(202), box(938), nullptr); - avl = gpr_avl_add(avl, box(308), box(939), nullptr); - avl = gpr_avl_add(avl, box(20), box(940), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(714), box(942), nullptr); - avl = gpr_avl_add(avl, box(584), box(943), nullptr); - avl = remove_int(avl, 294); - avl = gpr_avl_add(avl, box(496), box(945), nullptr); - avl = gpr_avl_add(avl, box(394), box(946), nullptr); - avl = gpr_avl_add(avl, box(860), box(947), nullptr); - avl = gpr_avl_add(avl, box(58), box(948), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 584); - avl = remove_int(avl, 708); - avl = gpr_avl_add(avl, box(142), box(952), nullptr); - avl = gpr_avl_add(avl, box(247), box(953), nullptr); - avl = gpr_avl_add(avl, box(389), box(954), nullptr); - avl = remove_int(avl, 390); - avl = gpr_avl_add(avl, box(465), box(956), nullptr); - avl = gpr_avl_add(avl, box(936), box(957), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(365), box(966), nullptr); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(728), box(968), nullptr); - avl = remove_int(avl, 852); - avl = gpr_avl_add(avl, box(884), box(970), nullptr); - avl = gpr_avl_add(avl, box(502), box(971), nullptr); - avl = remove_int(avl, 898); - avl = remove_int(avl, 481); - avl = gpr_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 = gpr_avl_add(avl, box(598), box(983), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 697); - avl = gpr_avl_add(avl, box(645), box(986), nullptr); - avl = gpr_avl_add(avl, box(211), box(987), nullptr); - avl = gpr_avl_add(avl, box(589), box(988), nullptr); - avl = remove_int(avl, 702); - avl = gpr_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 = gpr_avl_add(avl, box(74), box(997), nullptr); - avl = gpr_avl_add(avl, box(834), box(998), nullptr); - avl = gpr_avl_add(avl, box(514), box(999), nullptr); - avl = gpr_avl_add(avl, box(75), box(1000), nullptr); - avl = remove_int(avl, 745); - avl = gpr_avl_add(avl, box(362), box(1002), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(624), box(1004), nullptr); - avl = remove_int(avl, 404); - avl = remove_int(avl, 359); - avl = remove_int(avl, 491); - avl = gpr_avl_add(avl, box(903), box(1008), nullptr); - avl = gpr_avl_add(avl, box(240), box(1009), nullptr); - avl = remove_int(avl, 95); - avl = gpr_avl_add(avl, box(119), box(1011), nullptr); - avl = gpr_avl_add(avl, box(857), box(1012), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 866); - avl = gpr_avl_add(avl, box(503), box(1015), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(625), box(1023), nullptr); - avl = remove_int(avl, 638); - avl = gpr_avl_add(avl, box(299), box(1025), nullptr); - avl = gpr_avl_add(avl, box(584), box(1026), nullptr); - avl = remove_int(avl, 863); - avl = gpr_avl_add(avl, box(612), box(1028), nullptr); - avl = gpr_avl_add(avl, box(62), box(1029), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(703), box(1035), nullptr); - avl = gpr_avl_add(avl, box(644), box(1036), nullptr); - avl = remove_int(avl, 638); - avl = gpr_avl_add(avl, box(13), box(1038), nullptr); - avl = remove_int(avl, 66); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(362), box(1041), nullptr); - avl = gpr_avl_add(avl, box(783), box(1042), nullptr); - avl = remove_int(avl, 60); - avl = gpr_avl_add(avl, box(80), box(1044), nullptr); - avl = gpr_avl_add(avl, box(825), box(1045), nullptr); - avl = gpr_avl_add(avl, box(688), box(1046), nullptr); - avl = gpr_avl_add(avl, box(662), box(1047), nullptr); - avl = remove_int(avl, 156); - avl = remove_int(avl, 376); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(526), box(1051), nullptr); - avl = gpr_avl_add(avl, box(168), box(1052), nullptr); - avl = remove_int(avl, 646); - avl = remove_int(avl, 380); - avl = remove_int(avl, 833); - avl = gpr_avl_add(avl, box(53), box(1056), nullptr); - avl = remove_int(avl, 105); - avl = gpr_avl_add(avl, box(373), box(1058), nullptr); - avl = gpr_avl_add(avl, box(184), box(1059), nullptr); - avl = remove_int(avl, 288); - avl = gpr_avl_add(avl, box(966), box(1061), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(406), box(1063), nullptr); - avl = remove_int(avl, 470); - avl = gpr_avl_add(avl, box(283), box(1065), nullptr); - avl = gpr_avl_add(avl, box(838), box(1066), nullptr); - avl = gpr_avl_add(avl, box(288), box(1067), nullptr); - avl = gpr_avl_add(avl, box(950), box(1068), nullptr); - avl = gpr_avl_add(avl, box(163), box(1069), nullptr); - avl = remove_int(avl, 623); - avl = remove_int(avl, 769); - avl = gpr_avl_add(avl, box(144), box(1072), nullptr); - avl = gpr_avl_add(avl, box(489), box(1073), nullptr); - avl = remove_int(avl, 15); - avl = gpr_avl_add(avl, box(971), box(1075), nullptr); - avl = remove_int(avl, 660); - avl = gpr_avl_add(avl, box(255), box(1077), nullptr); - avl = remove_int(avl, 494); - avl = gpr_avl_add(avl, box(109), box(1079), nullptr); - avl = gpr_avl_add(avl, box(420), box(1080), nullptr); - avl = gpr_avl_add(avl, box(509), box(1081), nullptr); - avl = remove_int(avl, 178); - avl = gpr_avl_add(avl, box(216), box(1083), nullptr); - avl = gpr_avl_add(avl, box(707), box(1084), nullptr); - avl = gpr_avl_add(avl, box(411), box(1085), nullptr); - avl = gpr_avl_add(avl, box(352), box(1086), nullptr); - avl = remove_int(avl, 983); - avl = gpr_avl_add(avl, box(6), box(1088), nullptr); - avl = gpr_avl_add(avl, box(1014), box(1089), nullptr); - avl = remove_int(avl, 98); - avl = remove_int(avl, 325); - avl = gpr_avl_add(avl, box(851), box(1092), nullptr); - avl = remove_int(avl, 553); - avl = gpr_avl_add(avl, box(218), box(1094), nullptr); - avl = gpr_avl_add(avl, box(261), box(1095), nullptr); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(872), box(1097), nullptr); - avl = remove_int(avl, 543); - avl = remove_int(avl, 314); - avl = remove_int(avl, 443); - avl = gpr_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 = gpr_avl_add(avl, box(965), box(1110), nullptr); - avl = remove_int(avl, 622); - avl = gpr_avl_add(avl, box(352), box(1112), nullptr); - avl = remove_int(avl, 182); - avl = gpr_avl_add(avl, box(534), box(1114), nullptr); - avl = gpr_avl_add(avl, box(97), box(1115), nullptr); - avl = gpr_avl_add(avl, box(198), box(1116), nullptr); - avl = remove_int(avl, 750); - avl = gpr_avl_add(avl, box(98), box(1118), nullptr); - avl = remove_int(avl, 943); - avl = gpr_avl_add(avl, box(254), box(1120), nullptr); - avl = gpr_avl_add(avl, box(30), box(1121), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 475); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(789), box(1125), nullptr); - avl = gpr_avl_add(avl, box(402), box(1126), nullptr); - avl = remove_int(avl, 1019); - avl = gpr_avl_add(avl, box(858), box(1128), nullptr); - avl = gpr_avl_add(avl, box(625), box(1129), nullptr); - avl = remove_int(avl, 675); - avl = remove_int(avl, 323); - avl = gpr_avl_add(avl, box(329), box(1132), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 44); - avl = gpr_avl_add(avl, box(443), box(1135), nullptr); - avl = gpr_avl_add(avl, box(653), box(1136), nullptr); - avl = gpr_avl_add(avl, box(750), box(1137), nullptr); - avl = gpr_avl_add(avl, box(252), box(1138), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(531), box(1144), nullptr); - avl = remove_int(avl, 806); - avl = gpr_avl_add(avl, box(455), box(1146), nullptr); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(154), box(1148), nullptr); - avl = gpr_avl_add(avl, box(189), box(1149), nullptr); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(496), box(1151), nullptr); - avl = gpr_avl_add(avl, box(81), box(1152), nullptr); - avl = gpr_avl_add(avl, box(59), box(1153), nullptr); - avl = remove_int(avl, 424); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(723), box(1156), nullptr); - avl = gpr_avl_add(avl, box(822), box(1157), nullptr); - avl = gpr_avl_add(avl, box(354), box(1158), nullptr); - avl = remove_int(avl, 738); - avl = gpr_avl_add(avl, box(686), box(1160), nullptr); - avl = gpr_avl_add(avl, box(43), box(1161), nullptr); - avl = gpr_avl_add(avl, box(625), box(1162), nullptr); - avl = gpr_avl_add(avl, box(902), box(1163), nullptr); - avl = gpr_avl_add(avl, box(12), box(1164), nullptr); - avl = gpr_avl_add(avl, box(977), box(1165), nullptr); - avl = gpr_avl_add(avl, box(699), box(1166), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(759), box(1172), nullptr); - avl = remove_int(avl, 758); - avl = remove_int(avl, 222); - avl = gpr_avl_add(avl, box(975), box(1175), nullptr); - avl = remove_int(avl, 993); - avl = gpr_avl_add(avl, box(2), box(1177), nullptr); - avl = gpr_avl_add(avl, box(70), box(1178), nullptr); - avl = remove_int(avl, 350); - avl = remove_int(avl, 972); - avl = remove_int(avl, 880); - avl = gpr_avl_add(avl, box(753), box(1182), nullptr); - avl = remove_int(avl, 404); - avl = gpr_avl_add(avl, box(294), box(1184), nullptr); - avl = remove_int(avl, 474); - avl = gpr_avl_add(avl, box(228), box(1186), nullptr); - avl = gpr_avl_add(avl, box(484), box(1187), nullptr); - avl = remove_int(avl, 238); - avl = remove_int(avl, 53); - avl = remove_int(avl, 691); - avl = gpr_avl_add(avl, box(345), box(1191), nullptr); - avl = remove_int(avl, 0); - avl = gpr_avl_add(avl, box(230), box(1193), nullptr); - avl = remove_int(avl, 227); - avl = remove_int(avl, 152); - avl = gpr_avl_add(avl, box(884), box(1196), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 53); - avl = gpr_avl_add(avl, box(1015), box(1199), nullptr); - avl = gpr_avl_add(avl, box(697), box(1200), nullptr); - avl = gpr_avl_add(avl, box(376), box(1201), nullptr); - avl = remove_int(avl, 411); - avl = gpr_avl_add(avl, box(888), box(1203), nullptr); - avl = remove_int(avl, 55); - avl = gpr_avl_add(avl, box(85), box(1205), nullptr); - avl = remove_int(avl, 947); - avl = remove_int(avl, 382); - avl = remove_int(avl, 777); - avl = gpr_avl_add(avl, box(1017), box(1209), nullptr); - avl = gpr_avl_add(avl, box(169), box(1210), nullptr); - avl = gpr_avl_add(avl, box(156), box(1211), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 642); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(554), box(1215), nullptr); - avl = gpr_avl_add(avl, box(76), box(1216), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(523), box(1226), nullptr); - avl = gpr_avl_add(avl, box(712), box(1227), nullptr); - avl = gpr_avl_add(avl, box(474), box(1228), nullptr); - avl = gpr_avl_add(avl, box(882), box(1229), nullptr); - avl = gpr_avl_add(avl, box(965), box(1230), nullptr); - avl = remove_int(avl, 464); - avl = gpr_avl_add(avl, box(319), box(1232), nullptr); - avl = gpr_avl_add(avl, box(504), box(1233), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(884), box(1235), nullptr); - avl = gpr_avl_add(avl, box(813), box(1236), nullptr); - avl = gpr_avl_add(avl, box(795), box(1237), nullptr); - avl = remove_int(avl, 306); - avl = gpr_avl_add(avl, box(799), box(1239), nullptr); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(480), box(1241), nullptr); - avl = gpr_avl_add(avl, box(656), box(1242), nullptr); - avl = gpr_avl_add(avl, box(709), box(1243), nullptr); - avl = gpr_avl_add(avl, box(500), box(1244), nullptr); - avl = remove_int(avl, 740); - avl = gpr_avl_add(avl, box(980), box(1246), nullptr); - avl = gpr_avl_add(avl, box(458), box(1247), nullptr); - avl = remove_int(avl, 377); - avl = remove_int(avl, 338); - avl = gpr_avl_add(avl, box(554), box(1250), nullptr); - avl = gpr_avl_add(avl, box(504), box(1251), nullptr); - avl = gpr_avl_add(avl, box(603), box(1252), nullptr); - avl = gpr_avl_add(avl, box(761), box(1253), nullptr); - avl = remove_int(avl, 431); - avl = gpr_avl_add(avl, box(707), box(1255), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(645), box(1264), nullptr); - avl = remove_int(avl, 858); - avl = remove_int(avl, 997); - avl = gpr_avl_add(avl, box(519), box(1267), nullptr); - avl = remove_int(avl, 614); - avl = remove_int(avl, 462); - avl = remove_int(avl, 792); - avl = gpr_avl_add(avl, box(987), box(1271), nullptr); - avl = gpr_avl_add(avl, box(309), box(1272), nullptr); - avl = remove_int(avl, 747); - avl = gpr_avl_add(avl, box(621), box(1274), nullptr); - avl = gpr_avl_add(avl, box(450), box(1275), nullptr); - avl = remove_int(avl, 265); - avl = remove_int(avl, 8); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(238), box(1279), nullptr); - avl = remove_int(avl, 241); - avl = gpr_avl_add(avl, box(180), box(1281), nullptr); - avl = gpr_avl_add(avl, box(411), box(1282), nullptr); - avl = gpr_avl_add(avl, box(791), box(1283), nullptr); - avl = gpr_avl_add(avl, box(955), box(1284), nullptr); - avl = remove_int(avl, 24); - avl = remove_int(avl, 375); - avl = gpr_avl_add(avl, box(140), box(1287), nullptr); - avl = remove_int(avl, 949); - avl = gpr_avl_add(avl, box(301), box(1289), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(814), box(1295), nullptr); - avl = gpr_avl_add(avl, box(127), box(1296), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(310), box(1303), nullptr); - avl = gpr_avl_add(avl, box(304), box(1304), nullptr); - avl = gpr_avl_add(avl, box(1), box(1305), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(313), box(1312), nullptr); - avl = remove_int(avl, 85); - avl = gpr_avl_add(avl, box(964), box(1314), nullptr); - avl = gpr_avl_add(avl, box(559), box(1315), nullptr); - avl = remove_int(avl, 167); - avl = gpr_avl_add(avl, box(866), box(1317), nullptr); - avl = remove_int(avl, 275); - avl = gpr_avl_add(avl, box(173), box(1319), nullptr); - avl = gpr_avl_add(avl, box(765), box(1320), nullptr); - avl = remove_int(avl, 883); - avl = gpr_avl_add(avl, box(547), box(1322), nullptr); - avl = gpr_avl_add(avl, box(847), box(1323), nullptr); - avl = remove_int(avl, 817); - avl = remove_int(avl, 850); - avl = remove_int(avl, 718); - avl = gpr_avl_add(avl, box(806), box(1327), nullptr); - avl = gpr_avl_add(avl, box(360), box(1328), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(493), box(1330), nullptr); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(361), box(1332), nullptr); - avl = remove_int(avl, 355); - avl = gpr_avl_add(avl, box(512), box(1334), nullptr); - avl = gpr_avl_add(avl, box(191), box(1335), nullptr); - avl = remove_int(avl, 703); - avl = gpr_avl_add(avl, box(333), box(1337), nullptr); - avl = remove_int(avl, 481); - avl = gpr_avl_add(avl, box(501), box(1339), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 510); - avl = gpr_avl_add(avl, box(793), box(1342), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(281), box(1348), nullptr); - avl = gpr_avl_add(avl, box(702), box(1349), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(246), box(1357), nullptr); - avl = gpr_avl_add(avl, box(455), box(1358), nullptr); - avl = remove_int(avl, 782); - avl = remove_int(avl, 682); - avl = gpr_avl_add(avl, box(243), box(1361), nullptr); - avl = gpr_avl_add(avl, box(109), box(1362), nullptr); - avl = gpr_avl_add(avl, box(452), box(1363), nullptr); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(159), box(1365), nullptr); - avl = remove_int(avl, 1023); - avl = gpr_avl_add(avl, box(129), box(1367), nullptr); - avl = gpr_avl_add(avl, box(537), box(1368), nullptr); - avl = remove_int(avl, 321); - avl = gpr_avl_add(avl, box(740), box(1370), nullptr); - avl = remove_int(avl, 45); - avl = remove_int(avl, 136); - avl = gpr_avl_add(avl, box(229), box(1373), nullptr); - avl = remove_int(avl, 772); - avl = gpr_avl_add(avl, box(181), box(1375), nullptr); - avl = remove_int(avl, 175); - avl = gpr_avl_add(avl, box(817), box(1377), nullptr); - avl = remove_int(avl, 956); - avl = gpr_avl_add(avl, box(675), box(1379), nullptr); - avl = gpr_avl_add(avl, box(375), box(1380), nullptr); - avl = remove_int(avl, 384); - avl = gpr_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 = gpr_avl_add(avl, box(890), box(1388), nullptr); - avl = gpr_avl_add(avl, box(293), box(1389), nullptr); - avl = remove_int(avl, 207); - avl = remove_int(avl, 46); - avl = gpr_avl_add(avl, box(899), box(1392), nullptr); - avl = gpr_avl_add(avl, box(666), box(1393), nullptr); - avl = gpr_avl_add(avl, box(85), box(1394), nullptr); - avl = gpr_avl_add(avl, box(914), box(1395), nullptr); - avl = gpr_avl_add(avl, box(128), box(1396), nullptr); - avl = gpr_avl_add(avl, box(835), box(1397), nullptr); - avl = gpr_avl_add(avl, box(787), box(1398), nullptr); - avl = gpr_avl_add(avl, box(649), box(1399), nullptr); - avl = gpr_avl_add(avl, box(723), box(1400), nullptr); - avl = remove_int(avl, 874); - avl = gpr_avl_add(avl, box(778), box(1402), nullptr); - avl = gpr_avl_add(avl, box(1015), box(1403), nullptr); - avl = gpr_avl_add(avl, box(59), box(1404), nullptr); - avl = gpr_avl_add(avl, box(259), box(1405), nullptr); - avl = gpr_avl_add(avl, box(758), box(1406), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(145), box(1408), nullptr); - avl = gpr_avl_add(avl, box(440), box(1409), nullptr); - avl = remove_int(avl, 608); - avl = remove_int(avl, 690); - avl = gpr_avl_add(avl, box(605), box(1412), nullptr); - avl = remove_int(avl, 856); - avl = remove_int(avl, 608); - avl = gpr_avl_add(avl, box(829), box(1415), nullptr); - avl = gpr_avl_add(avl, box(660), box(1416), nullptr); - avl = remove_int(avl, 596); - avl = gpr_avl_add(avl, box(519), box(1418), nullptr); - avl = gpr_avl_add(avl, box(35), box(1419), nullptr); - avl = gpr_avl_add(avl, box(871), box(1420), nullptr); - avl = remove_int(avl, 845); - avl = gpr_avl_add(avl, box(600), box(1422), nullptr); - avl = gpr_avl_add(avl, box(215), box(1423), nullptr); - avl = remove_int(avl, 761); - avl = gpr_avl_add(avl, box(975), box(1425), nullptr); - avl = remove_int(avl, 987); - avl = gpr_avl_add(avl, box(58), box(1427), nullptr); - avl = remove_int(avl, 119); - avl = gpr_avl_add(avl, box(937), box(1429), nullptr); - avl = gpr_avl_add(avl, box(372), box(1430), nullptr); - avl = gpr_avl_add(avl, box(11), box(1431), nullptr); - avl = gpr_avl_add(avl, box(398), box(1432), nullptr); - avl = gpr_avl_add(avl, box(423), box(1433), nullptr); - avl = remove_int(avl, 171); - avl = gpr_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 = gpr_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 = gpr_avl_add(avl, box(636), box(1446), nullptr); - avl = remove_int(avl, 152); - avl = gpr_avl_add(avl, box(61), box(1448), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 9); - avl = gpr_avl_add(avl, box(251), box(1451), nullptr); - avl = gpr_avl_add(avl, box(672), box(1452), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(618), box(1458), nullptr); - avl = gpr_avl_add(avl, box(495), box(1459), nullptr); - avl = remove_int(avl, 450); - avl = gpr_avl_add(avl, box(533), box(1461), nullptr); - avl = gpr_avl_add(avl, box(414), box(1462), nullptr); - avl = remove_int(avl, 74); - avl = remove_int(avl, 236); - avl = gpr_avl_add(avl, box(707), box(1465), nullptr); - avl = gpr_avl_add(avl, box(357), box(1466), nullptr); - avl = gpr_avl_add(avl, box(1007), box(1467), nullptr); - avl = gpr_avl_add(avl, box(811), box(1468), nullptr); - avl = gpr_avl_add(avl, box(418), box(1469), nullptr); - avl = gpr_avl_add(avl, box(164), box(1470), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(221), box(1477), nullptr); - avl = gpr_avl_add(avl, box(202), box(1478), nullptr); - avl = gpr_avl_add(avl, box(312), box(1479), nullptr); - avl = remove_int(avl, 274); - avl = gpr_avl_add(avl, box(684), box(1481), nullptr); - avl = gpr_avl_add(avl, box(954), box(1482), nullptr); - avl = gpr_avl_add(avl, box(637), box(1483), nullptr); - avl = remove_int(avl, 716); - avl = gpr_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 = gpr_avl_add(avl, box(661), box(1490), nullptr); - avl = gpr_avl_add(avl, box(862), box(1491), nullptr); - avl = remove_int(avl, 527); - avl = gpr_avl_add(avl, box(945), box(1493), nullptr); - avl = remove_int(avl, 355); - avl = remove_int(avl, 144); - avl = gpr_avl_add(avl, box(229), box(1496), nullptr); - avl = gpr_avl_add(avl, box(237), box(1497), nullptr); - avl = remove_int(avl, 471); - avl = remove_int(avl, 901); - avl = gpr_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 = gpr_avl_add(avl, box(547), box(1505), nullptr); - avl = gpr_avl_add(avl, box(552), box(1506), nullptr); - avl = gpr_avl_add(avl, box(30), box(1507), nullptr); - avl = gpr_avl_add(avl, box(445), box(1508), nullptr); - avl = remove_int(avl, 785); - avl = remove_int(avl, 185); - avl = gpr_avl_add(avl, box(405), box(1511), nullptr); - avl = gpr_avl_add(avl, box(733), box(1512), nullptr); - avl = gpr_avl_add(avl, box(573), box(1513), nullptr); - avl = gpr_avl_add(avl, box(492), box(1514), nullptr); - avl = gpr_avl_add(avl, box(343), box(1515), nullptr); - avl = gpr_avl_add(avl, box(527), box(1516), nullptr); - avl = gpr_avl_add(avl, box(596), box(1517), nullptr); - avl = gpr_avl_add(avl, box(519), box(1518), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 722); - avl = gpr_avl_add(avl, box(772), box(1521), nullptr); - avl = remove_int(avl, 152); - avl = remove_int(avl, 305); - avl = gpr_avl_add(avl, box(754), box(1524), nullptr); - avl = gpr_avl_add(avl, box(373), box(1525), nullptr); - avl = remove_int(avl, 995); - avl = gpr_avl_add(avl, box(329), box(1527), nullptr); - avl = remove_int(avl, 397); - avl = gpr_avl_add(avl, box(884), box(1529), nullptr); - avl = remove_int(avl, 329); - avl = remove_int(avl, 240); - avl = gpr_avl_add(avl, box(566), box(1532), nullptr); - avl = gpr_avl_add(avl, box(232), box(1533), nullptr); - avl = remove_int(avl, 993); - avl = gpr_avl_add(avl, box(888), box(1535), nullptr); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(941), box(1537), nullptr); - avl = remove_int(avl, 415); - avl = gpr_avl_add(avl, box(992), box(1539), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(60), box(1541), nullptr); - avl = gpr_avl_add(avl, box(97), box(1542), nullptr); - avl = remove_int(avl, 965); - avl = remove_int(avl, 267); - avl = remove_int(avl, 360); - avl = gpr_avl_add(avl, box(5), box(1546), nullptr); - avl = remove_int(avl, 429); - avl = gpr_avl_add(avl, box(412), box(1548), nullptr); - avl = remove_int(avl, 632); - avl = remove_int(avl, 113); - avl = gpr_avl_add(avl, box(48), box(1551), nullptr); - avl = gpr_avl_add(avl, box(108), box(1552), nullptr); - avl = gpr_avl_add(avl, box(750), box(1553), nullptr); - avl = remove_int(avl, 188); - avl = gpr_avl_add(avl, box(668), box(1555), nullptr); - avl = remove_int(avl, 37); - avl = remove_int(avl, 737); - avl = gpr_avl_add(avl, box(93), box(1558), nullptr); - avl = gpr_avl_add(avl, box(628), box(1559), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(136), box(1566), nullptr); - avl = gpr_avl_add(avl, box(469), box(1567), nullptr); - avl = remove_int(avl, 349); - avl = gpr_avl_add(avl, box(768), box(1569), nullptr); - avl = gpr_avl_add(avl, box(915), box(1570), nullptr); - avl = remove_int(avl, 1014); - avl = gpr_avl_add(avl, box(117), box(1572), nullptr); - avl = remove_int(avl, 62); - avl = gpr_avl_add(avl, box(382), box(1574), nullptr); - avl = remove_int(avl, 571); - avl = gpr_avl_add(avl, box(655), box(1576), nullptr); - avl = gpr_avl_add(avl, box(323), box(1577), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(1019), box(1580), nullptr); - avl = gpr_avl_add(avl, box(984), box(1581), nullptr); - avl = gpr_avl_add(avl, box(870), box(1582), nullptr); - avl = gpr_avl_add(avl, box(376), box(1583), nullptr); - avl = remove_int(avl, 625); - avl = gpr_avl_add(avl, box(733), box(1585), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 444); - avl = gpr_avl_add(avl, box(428), box(1588), nullptr); - avl = gpr_avl_add(avl, box(860), box(1589), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(604), box(1595), nullptr); - avl = gpr_avl_add(avl, box(639), box(1596), nullptr); - avl = remove_int(avl, 431); - avl = gpr_avl_add(avl, box(993), box(1598), nullptr); - avl = remove_int(avl, 681); - avl = remove_int(avl, 927); - avl = gpr_avl_add(avl, box(87), box(1601), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(903), box(1608), nullptr); - avl = gpr_avl_add(avl, box(951), box(1609), nullptr); - avl = gpr_avl_add(avl, box(146), box(1610), nullptr); - avl = gpr_avl_add(avl, box(482), box(1611), nullptr); - avl = gpr_avl_add(avl, box(71), box(1612), nullptr); - avl = remove_int(avl, 246); - avl = remove_int(avl, 696); - avl = gpr_avl_add(avl, box(636), box(1615), nullptr); - avl = gpr_avl_add(avl, box(295), box(1616), nullptr); - avl = remove_int(avl, 11); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(905), box(1619), nullptr); - avl = gpr_avl_add(avl, box(993), box(1620), nullptr); - avl = gpr_avl_add(avl, box(433), box(1621), nullptr); - avl = gpr_avl_add(avl, box(117), box(1622), nullptr); - avl = gpr_avl_add(avl, box(467), box(1623), nullptr); - avl = remove_int(avl, 419); - avl = gpr_avl_add(avl, box(179), box(1625), nullptr); - avl = remove_int(avl, 926); - avl = remove_int(avl, 326); - avl = gpr_avl_add(avl, box(551), box(1628), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 476); - avl = remove_int(avl, 823); - avl = gpr_avl_add(avl, box(350), box(1632), nullptr); - avl = gpr_avl_add(avl, box(133), box(1633), nullptr); - avl = remove_int(avl, 906); - avl = gpr_avl_add(avl, box(827), box(1635), nullptr); - avl = gpr_avl_add(avl, box(201), box(1636), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 662); - avl = gpr_avl_add(avl, box(314), box(1639), nullptr); - avl = gpr_avl_add(avl, box(986), box(1640), nullptr); - avl = gpr_avl_add(avl, box(622), box(1641), nullptr); - avl = remove_int(avl, 130); - avl = gpr_avl_add(avl, box(861), box(1643), nullptr); - avl = remove_int(avl, 497); - avl = remove_int(avl, 905); - avl = gpr_avl_add(avl, box(502), box(1646), nullptr); - avl = remove_int(avl, 721); - avl = gpr_avl_add(avl, box(514), box(1648), nullptr); - avl = gpr_avl_add(avl, box(410), box(1649), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 247); - avl = gpr_avl_add(avl, box(450), box(1652), nullptr); - avl = remove_int(avl, 364); - avl = gpr_avl_add(avl, box(963), box(1654), nullptr); - avl = gpr_avl_add(avl, box(146), box(1655), nullptr); - avl = remove_int(avl, 147); - avl = remove_int(avl, 789); - avl = gpr_avl_add(avl, box(693), box(1658), nullptr); - avl = gpr_avl_add(avl, box(959), box(1659), nullptr); - avl = remove_int(avl, 478); - avl = gpr_avl_add(avl, box(116), box(1661), nullptr); - avl = gpr_avl_add(avl, box(520), box(1662), nullptr); - avl = gpr_avl_add(avl, box(809), box(1663), nullptr); - avl = gpr_avl_add(avl, box(667), box(1664), nullptr); - avl = gpr_avl_add(avl, box(406), box(1665), nullptr); - avl = remove_int(avl, 409); - avl = gpr_avl_add(avl, box(558), box(1667), nullptr); - avl = gpr_avl_add(avl, box(0), box(1668), nullptr); - avl = gpr_avl_add(avl, box(948), box(1669), nullptr); - avl = gpr_avl_add(avl, box(576), box(1670), nullptr); - avl = remove_int(avl, 864); - avl = remove_int(avl, 840); - avl = remove_int(avl, 1001); - avl = gpr_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 = gpr_avl_add(avl, box(258), box(1679), nullptr); - avl = gpr_avl_add(avl, box(648), box(1680), nullptr); - avl = gpr_avl_add(avl, box(761), box(1681), nullptr); - avl = remove_int(avl, 293); - avl = remove_int(avl, 893); - avl = gpr_avl_add(avl, box(194), box(1684), nullptr); - avl = remove_int(avl, 233); - avl = gpr_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 = gpr_avl_add(avl, box(621), box(1691), nullptr); - avl = remove_int(avl, 634); - avl = remove_int(avl, 335); - avl = gpr_avl_add(avl, box(718), box(1694), nullptr); - avl = gpr_avl_add(avl, box(463), box(1695), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(607), box(1703), nullptr); - avl = remove_int(avl, 329); - avl = gpr_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 = gpr_avl_add(avl, box(414), box(1713), nullptr); - avl = gpr_avl_add(avl, box(212), box(1714), nullptr); - avl = gpr_avl_add(avl, box(266), box(1715), nullptr); - avl = gpr_avl_add(avl, box(238), box(1716), nullptr); - avl = remove_int(avl, 153); - avl = gpr_avl_add(avl, box(585), box(1718), nullptr); - avl = remove_int(avl, 121); - avl = gpr_avl_add(avl, box(534), box(1720), nullptr); - avl = remove_int(avl, 579); - avl = gpr_avl_add(avl, box(127), box(1722), nullptr); - avl = gpr_avl_add(avl, box(399), box(1723), nullptr); - avl = remove_int(avl, 417); - avl = gpr_avl_add(avl, box(978), box(1725), nullptr); - avl = gpr_avl_add(avl, box(768), box(1726), nullptr); - avl = remove_int(avl, 985); - avl = gpr_avl_add(avl, box(536), box(1728), nullptr); - avl = gpr_avl_add(avl, box(449), box(1729), nullptr); - avl = gpr_avl_add(avl, box(586), box(1730), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 394); - avl = remove_int(avl, 141); - avl = gpr_avl_add(avl, box(889), box(1734), nullptr); - avl = gpr_avl_add(avl, box(871), box(1735), nullptr); - avl = gpr_avl_add(avl, box(76), box(1736), nullptr); - avl = gpr_avl_add(avl, box(549), box(1737), nullptr); - avl = gpr_avl_add(avl, box(757), box(1738), nullptr); - avl = remove_int(avl, 908); - avl = gpr_avl_add(avl, box(789), box(1740), nullptr); - avl = remove_int(avl, 224); - avl = gpr_avl_add(avl, box(407), box(1742), nullptr); - avl = gpr_avl_add(avl, box(381), box(1743), nullptr); - avl = gpr_avl_add(avl, box(561), box(1744), nullptr); - avl = gpr_avl_add(avl, box(667), box(1745), nullptr); - avl = gpr_avl_add(avl, box(522), box(1746), nullptr); - avl = gpr_avl_add(avl, box(948), box(1747), nullptr); - avl = remove_int(avl, 770); - avl = gpr_avl_add(avl, box(872), box(1749), nullptr); - avl = gpr_avl_add(avl, box(327), box(1750), nullptr); - avl = remove_int(avl, 10); - avl = gpr_avl_add(avl, box(122), box(1752), nullptr); - avl = remove_int(avl, 606); - avl = gpr_avl_add(avl, box(485), box(1754), nullptr); - avl = remove_int(avl, 6); - avl = gpr_avl_add(avl, box(329), box(1756), nullptr); - avl = gpr_avl_add(avl, box(783), box(1757), nullptr); - avl = remove_int(avl, 416); - avl = gpr_avl_add(avl, box(656), box(1759), nullptr); - avl = gpr_avl_add(avl, box(971), box(1760), nullptr); - avl = gpr_avl_add(avl, box(77), box(1761), nullptr); - avl = gpr_avl_add(avl, box(942), box(1762), nullptr); - avl = remove_int(avl, 361); - avl = gpr_avl_add(avl, box(66), box(1764), nullptr); - avl = gpr_avl_add(avl, box(299), box(1765), nullptr); - avl = gpr_avl_add(avl, box(929), box(1766), nullptr); - avl = gpr_avl_add(avl, box(797), box(1767), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 907); - avl = gpr_avl_add(avl, box(870), box(1770), nullptr); - avl = remove_int(avl, 580); - avl = remove_int(avl, 120); - avl = gpr_avl_add(avl, box(913), box(1773), nullptr); - avl = remove_int(avl, 480); - avl = gpr_avl_add(avl, box(489), box(1775), nullptr); - avl = remove_int(avl, 845); - avl = gpr_avl_add(avl, box(896), box(1777), nullptr); - avl = remove_int(avl, 567); - avl = remove_int(avl, 427); - avl = gpr_avl_add(avl, box(443), box(1780), nullptr); - avl = gpr_avl_add(avl, box(3), box(1781), nullptr); - avl = remove_int(avl, 12); - avl = gpr_avl_add(avl, box(376), box(1783), nullptr); - avl = gpr_avl_add(avl, box(155), box(1784), nullptr); - avl = gpr_avl_add(avl, box(188), box(1785), nullptr); - avl = gpr_avl_add(avl, box(149), box(1786), nullptr); - avl = gpr_avl_add(avl, box(178), box(1787), nullptr); - avl = remove_int(avl, 84); - avl = gpr_avl_add(avl, box(805), box(1789), nullptr); - avl = gpr_avl_add(avl, box(612), box(1790), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(837), box(1792), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 72); - avl = gpr_avl_add(avl, box(1014), box(1795), nullptr); - avl = remove_int(avl, 303); - avl = gpr_avl_add(avl, box(865), box(1797), nullptr); - avl = gpr_avl_add(avl, box(793), box(1798), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 477); - avl = gpr_avl_add(avl, box(950), box(1801), nullptr); - avl = gpr_avl_add(avl, box(105), box(1802), nullptr); - avl = gpr_avl_add(avl, box(895), box(1803), nullptr); - avl = gpr_avl_add(avl, box(171), box(1804), nullptr); - avl = gpr_avl_add(avl, box(753), box(1805), nullptr); - avl = gpr_avl_add(avl, box(946), box(1806), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 559); - avl = remove_int(avl, 116); - avl = gpr_avl_add(avl, box(968), box(1810), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(563), box(1813), nullptr); - avl = remove_int(avl, 182); - avl = gpr_avl_add(avl, box(816), box(1815), nullptr); - avl = remove_int(avl, 73); - avl = remove_int(avl, 261); - avl = gpr_avl_add(avl, box(847), box(1818), nullptr); - avl = gpr_avl_add(avl, box(368), box(1819), nullptr); - avl = gpr_avl_add(avl, box(808), box(1820), nullptr); - avl = gpr_avl_add(avl, box(779), box(1821), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(466), box(1823), nullptr); - avl = remove_int(avl, 316); - avl = gpr_avl_add(avl, box(986), box(1825), nullptr); - avl = gpr_avl_add(avl, box(688), box(1826), nullptr); - avl = gpr_avl_add(avl, box(509), box(1827), nullptr); - avl = gpr_avl_add(avl, box(51), box(1828), nullptr); - avl = remove_int(avl, 655); - avl = remove_int(avl, 785); - avl = remove_int(avl, 893); - avl = gpr_avl_add(avl, box(167), box(1832), nullptr); - avl = remove_int(avl, 13); - avl = remove_int(avl, 263); - avl = gpr_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 = gpr_avl_add(avl, box(803), box(1840), nullptr); - avl = remove_int(avl, 267); - avl = gpr_avl_add(avl, box(676), box(1842), nullptr); - avl = gpr_avl_add(avl, box(231), box(1843), nullptr); - avl = gpr_avl_add(avl, box(824), box(1844), nullptr); - avl = remove_int(avl, 961); - avl = gpr_avl_add(avl, box(311), box(1846), nullptr); - avl = gpr_avl_add(avl, box(420), box(1847), nullptr); - avl = gpr_avl_add(avl, box(960), box(1848), nullptr); - avl = gpr_avl_add(avl, box(468), box(1849), nullptr); - avl = gpr_avl_add(avl, box(815), box(1850), nullptr); - avl = remove_int(avl, 247); - avl = remove_int(avl, 194); - avl = gpr_avl_add(avl, box(546), box(1853), nullptr); - avl = remove_int(avl, 222); - avl = remove_int(avl, 914); - avl = remove_int(avl, 741); - avl = gpr_avl_add(avl, box(470), box(1857), nullptr); - avl = gpr_avl_add(avl, box(933), box(1858), nullptr); - avl = gpr_avl_add(avl, box(97), box(1859), nullptr); - avl = remove_int(avl, 564); - avl = remove_int(avl, 295); - avl = gpr_avl_add(avl, box(864), box(1862), nullptr); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(124), box(1864), nullptr); - avl = gpr_avl_add(avl, box(1000), box(1865), nullptr); - avl = gpr_avl_add(avl, box(228), box(1866), nullptr); - avl = gpr_avl_add(avl, box(187), box(1867), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 306); - avl = remove_int(avl, 884); - avl = gpr_avl_add(avl, box(449), box(1871), nullptr); - avl = gpr_avl_add(avl, box(353), box(1872), nullptr); - avl = gpr_avl_add(avl, box(994), box(1873), nullptr); - avl = gpr_avl_add(avl, box(596), box(1874), nullptr); - avl = gpr_avl_add(avl, box(996), box(1875), nullptr); - avl = gpr_avl_add(avl, box(101), box(1876), nullptr); - avl = gpr_avl_add(avl, box(1012), box(1877), nullptr); - avl = gpr_avl_add(avl, box(982), box(1878), nullptr); - avl = gpr_avl_add(avl, box(742), box(1879), nullptr); - avl = remove_int(avl, 92); - avl = remove_int(avl, 1022); - avl = gpr_avl_add(avl, box(941), box(1882), nullptr); - avl = remove_int(avl, 742); - avl = remove_int(avl, 919); - avl = gpr_avl_add(avl, box(588), box(1885), nullptr); - avl = remove_int(avl, 221); - avl = gpr_avl_add(avl, box(356), box(1887), nullptr); - avl = gpr_avl_add(avl, box(932), box(1888), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(394), box(1890), nullptr); - avl = gpr_avl_add(avl, box(642), box(1891), nullptr); - avl = gpr_avl_add(avl, box(52), box(1892), nullptr); - avl = gpr_avl_add(avl, box(437), box(1893), nullptr); - avl = gpr_avl_add(avl, box(948), box(1894), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(80), box(1900), nullptr); - avl = gpr_avl_add(avl, box(952), box(1901), nullptr); - avl = gpr_avl_add(avl, box(510), box(1902), nullptr); - avl = remove_int(avl, 876); - avl = remove_int(avl, 612); - avl = gpr_avl_add(avl, box(923), box(1905), nullptr); - avl = gpr_avl_add(avl, box(475), box(1906), nullptr); - avl = remove_int(avl, 478); - avl = remove_int(avl, 148); - avl = gpr_avl_add(avl, box(538), box(1909), nullptr); - avl = remove_int(avl, 47); - avl = gpr_avl_add(avl, box(89), box(1911), nullptr); - avl = remove_int(avl, 723); - avl = gpr_avl_add(avl, box(687), box(1913), nullptr); - avl = gpr_avl_add(avl, box(480), box(1914), nullptr); - avl = gpr_avl_add(avl, box(149), box(1915), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 862); - avl = remove_int(avl, 363); - avl = gpr_avl_add(avl, box(996), box(1919), nullptr); - avl = remove_int(avl, 380); - avl = gpr_avl_add(avl, box(957), box(1921), nullptr); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(360), box(1923), nullptr); - avl = gpr_avl_add(avl, box(304), box(1924), nullptr); - avl = gpr_avl_add(avl, box(634), box(1925), nullptr); - avl = gpr_avl_add(avl, box(506), box(1926), nullptr); - avl = remove_int(avl, 248); - avl = gpr_avl_add(avl, box(124), box(1928), nullptr); - avl = gpr_avl_add(avl, box(181), box(1929), nullptr); - avl = remove_int(avl, 507); - avl = gpr_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 = gpr_avl_add(avl, box(998), box(1936), nullptr); - avl = gpr_avl_add(avl, box(906), box(1937), nullptr); - avl = gpr_avl_add(avl, box(44), box(1938), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 117); - avl = gpr_avl_add(avl, box(700), box(1941), nullptr); - avl = gpr_avl_add(avl, box(258), box(1942), nullptr); - avl = remove_int(avl, 828); - avl = gpr_avl_add(avl, box(860), box(1944), nullptr); - avl = gpr_avl_add(avl, box(987), box(1945), nullptr); - avl = gpr_avl_add(avl, box(316), box(1946), nullptr); - avl = gpr_avl_add(avl, box(919), box(1947), nullptr); - avl = remove_int(avl, 84); - avl = gpr_avl_add(avl, box(473), box(1949), nullptr); - avl = remove_int(avl, 127); - avl = remove_int(avl, 829); - avl = remove_int(avl, 829); - avl = gpr_avl_add(avl, box(488), box(1953), nullptr); - avl = gpr_avl_add(avl, box(954), box(1954), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 972); - avl = remove_int(avl, 670); - avl = gpr_avl_add(avl, box(822), box(1958), nullptr); - avl = remove_int(avl, 589); - avl = remove_int(avl, 459); - avl = gpr_avl_add(avl, box(1003), box(1961), nullptr); - avl = gpr_avl_add(avl, box(657), box(1962), nullptr); - avl = gpr_avl_add(avl, box(477), box(1963), nullptr); - avl = gpr_avl_add(avl, box(923), box(1964), nullptr); - avl = remove_int(avl, 496); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(127), box(1967), nullptr); - avl = gpr_avl_add(avl, box(1013), box(1968), nullptr); - avl = gpr_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 = gpr_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 = gpr_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 = gpr_avl_add(avl, box(335), box(1985), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(545), box(1991), nullptr); - avl = gpr_avl_add(avl, box(408), box(1992), nullptr); - avl = gpr_avl_add(avl, box(841), box(1993), nullptr); - avl = remove_int(avl, 593); - avl = gpr_avl_add(avl, box(582), box(1995), nullptr); - avl = gpr_avl_add(avl, box(597), box(1996), nullptr); - avl = remove_int(avl, 49); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(417), box(1999), nullptr); - avl = gpr_avl_add(avl, box(191), box(2000), nullptr); - avl = remove_int(avl, 406); - avl = gpr_avl_add(avl, box(30), box(2002), nullptr); - avl = remove_int(avl, 841); - avl = remove_int(avl, 50); - avl = gpr_avl_add(avl, box(967), box(2005), nullptr); - avl = gpr_avl_add(avl, box(849), box(2006), nullptr); - avl = remove_int(avl, 608); - avl = gpr_avl_add(avl, box(306), box(2008), nullptr); - avl = remove_int(avl, 779); - avl = gpr_avl_add(avl, box(897), box(2010), nullptr); - avl = gpr_avl_add(avl, box(147), box(2011), nullptr); - avl = remove_int(avl, 982); - avl = gpr_avl_add(avl, box(470), box(2013), nullptr); - avl = remove_int(avl, 951); - avl = gpr_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 = gpr_avl_add(avl, box(218), box(2020), nullptr); - avl = remove_int(avl, 671); - avl = gpr_avl_add(avl, box(1020), box(2022), nullptr); - avl = remove_int(avl, 277); - avl = gpr_avl_add(avl, box(681), box(2024), nullptr); - avl = gpr_avl_add(avl, box(179), box(2025), nullptr); - avl = gpr_avl_add(avl, box(370), box(2026), nullptr); - avl = gpr_avl_add(avl, box(0), box(2027), nullptr); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(99), box(2029), nullptr); - avl = gpr_avl_add(avl, box(334), box(2030), nullptr); - avl = gpr_avl_add(avl, box(569), box(2031), nullptr); - avl = gpr_avl_add(avl, box(257), box(2032), nullptr); - avl = remove_int(avl, 572); - avl = gpr_avl_add(avl, box(805), box(2034), nullptr); - avl = gpr_avl_add(avl, box(143), box(2035), nullptr); - avl = gpr_avl_add(avl, box(670), box(2036), nullptr); - avl = remove_int(avl, 42); - avl = gpr_avl_add(avl, box(46), box(2038), nullptr); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(353), box(2040), nullptr); - avl = remove_int(avl, 258); - avl = gpr_avl_add(avl, box(451), box(2042), nullptr); - avl = gpr_avl_add(avl, box(28), box(2043), nullptr); - avl = gpr_avl_add(avl, box(729), box(2044), nullptr); - avl = gpr_avl_add(avl, box(401), box(2045), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(1016), box(2051), nullptr); - avl = gpr_avl_add(avl, box(980), box(2052), nullptr); - avl = gpr_avl_add(avl, box(990), box(2053), nullptr); - avl = gpr_avl_add(avl, box(355), box(2054), nullptr); - avl = remove_int(avl, 730); - avl = remove_int(avl, 37); - avl = gpr_avl_add(avl, box(407), box(2057), nullptr); - avl = gpr_avl_add(avl, box(222), box(2058), nullptr); - avl = gpr_avl_add(avl, box(439), box(2059), nullptr); - avl = gpr_avl_add(avl, box(563), box(2060), nullptr); - avl = remove_int(avl, 992); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(1), box(2063), nullptr); - avl = gpr_avl_add(avl, box(473), box(2064), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(329), box(2070), nullptr); - avl = gpr_avl_add(avl, box(35), box(2071), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(855), box(2073), nullptr); - avl = remove_int(avl, 878); - avl = gpr_avl_add(avl, box(993), box(2075), nullptr); - avl = gpr_avl_add(avl, box(87), box(2076), nullptr); - avl = gpr_avl_add(avl, box(572), box(2077), nullptr); - avl = remove_int(avl, 896); - avl = gpr_avl_add(avl, box(849), box(2079), nullptr); - avl = remove_int(avl, 597); - avl = gpr_avl_add(avl, box(472), box(2081), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 934); - avl = remove_int(avl, 314); - avl = gpr_avl_add(avl, box(101), box(2085), nullptr); - avl = remove_int(avl, 938); - avl = remove_int(avl, 1010); - avl = gpr_avl_add(avl, box(579), box(2088), nullptr); - avl = remove_int(avl, 798); - avl = remove_int(avl, 88); - avl = gpr_avl_add(avl, box(851), box(2091), nullptr); - avl = remove_int(avl, 705); - avl = gpr_avl_add(avl, box(26), box(2093), nullptr); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(923), box(2095), nullptr); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(310), box(2097), nullptr); - avl = gpr_avl_add(avl, box(269), box(2098), nullptr); - avl = remove_int(avl, 173); - avl = gpr_avl_add(avl, box(279), box(2100), nullptr); - avl = remove_int(avl, 203); - avl = gpr_avl_add(avl, box(411), box(2102), nullptr); - avl = remove_int(avl, 950); - avl = gpr_avl_add(avl, box(6), box(2104), nullptr); - avl = remove_int(avl, 400); - avl = remove_int(avl, 468); - avl = remove_int(avl, 271); - avl = gpr_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 = gpr_avl_add(avl, box(76), box(2117), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 18); - avl = gpr_avl_add(avl, box(727), box(2120), nullptr); - avl = remove_int(avl, 295); - avl = gpr_avl_add(avl, box(645), box(2122), nullptr); - avl = remove_int(avl, 321); - avl = remove_int(avl, 863); - avl = gpr_avl_add(avl, box(824), box(2125), nullptr); - avl = gpr_avl_add(avl, box(651), box(2126), nullptr); - avl = gpr_avl_add(avl, box(804), box(2127), nullptr); - avl = remove_int(avl, 307); - avl = gpr_avl_add(avl, box(867), box(2129), nullptr); - avl = remove_int(avl, 384); - avl = gpr_avl_add(avl, box(819), box(2131), nullptr); - avl = remove_int(avl, 674); - avl = gpr_avl_add(avl, box(76), box(2133), nullptr); - avl = remove_int(avl, 898); - avl = gpr_avl_add(avl, box(45), box(2135), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(348), box(2143), nullptr); - avl = remove_int(avl, 509); - avl = remove_int(avl, 301); - avl = gpr_avl_add(avl, box(861), box(2146), nullptr); - avl = gpr_avl_add(avl, box(918), box(2147), nullptr); - avl = remove_int(avl, 992); - avl = gpr_avl_add(avl, box(356), box(2149), nullptr); - avl = remove_int(avl, 64); - avl = remove_int(avl, 444); - avl = remove_int(avl, 741); - avl = gpr_avl_add(avl, box(710), box(2153), nullptr); - avl = gpr_avl_add(avl, box(264), box(2154), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 250); - avl = gpr_avl_add(avl, box(82), box(2157), nullptr); - avl = gpr_avl_add(avl, box(571), box(2158), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 622); - avl = gpr_avl_add(avl, box(950), box(2161), nullptr); - avl = gpr_avl_add(avl, box(94), box(2162), nullptr); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(815), box(2164), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 703); - avl = gpr_avl_add(avl, box(432), box(2167), nullptr); - avl = remove_int(avl, 544); - avl = gpr_avl_add(avl, box(21), box(2169), nullptr); - avl = gpr_avl_add(avl, box(186), box(2170), nullptr); - avl = remove_int(avl, 143); - avl = gpr_avl_add(avl, box(425), box(2172), nullptr); - avl = remove_int(avl, 769); - avl = gpr_avl_add(avl, box(656), box(2174), nullptr); - avl = remove_int(avl, 29); - avl = gpr_avl_add(avl, box(464), box(2176), nullptr); - avl = remove_int(avl, 713); - avl = gpr_avl_add(avl, box(800), box(2178), nullptr); - avl = remove_int(avl, 621); - avl = gpr_avl_add(avl, box(962), box(2180), nullptr); - avl = remove_int(avl, 448); - avl = gpr_avl_add(avl, box(878), box(2182), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 999); - avl = gpr_avl_add(avl, box(182), box(2185), nullptr); - avl = gpr_avl_add(avl, box(429), box(2186), nullptr); - avl = gpr_avl_add(avl, box(598), box(2187), nullptr); - avl = remove_int(avl, 551); - avl = gpr_avl_add(avl, box(827), box(2189), nullptr); - avl = gpr_avl_add(avl, box(809), box(2190), nullptr); - avl = remove_int(avl, 438); - avl = remove_int(avl, 811); - avl = gpr_avl_add(avl, box(808), box(2193), nullptr); - avl = gpr_avl_add(avl, box(788), box(2194), nullptr); - avl = remove_int(avl, 156); - avl = gpr_avl_add(avl, box(933), box(2196), nullptr); - avl = gpr_avl_add(avl, box(344), box(2197), nullptr); - avl = remove_int(avl, 460); - avl = gpr_avl_add(avl, box(161), box(2199), nullptr); - avl = gpr_avl_add(avl, box(444), box(2200), nullptr); - avl = remove_int(avl, 597); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(703), box(2203), nullptr); - avl = remove_int(avl, 515); - avl = gpr_avl_add(avl, box(380), box(2205), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(413), box(2211), nullptr); - avl = remove_int(avl, 450); - avl = gpr_avl_add(avl, box(411), box(2213), nullptr); - avl = gpr_avl_add(avl, box(117), box(2214), nullptr); - avl = gpr_avl_add(avl, box(322), box(2215), nullptr); - avl = gpr_avl_add(avl, box(915), box(2216), nullptr); - avl = gpr_avl_add(avl, box(410), box(2217), nullptr); - avl = gpr_avl_add(avl, box(66), box(2218), nullptr); - avl = remove_int(avl, 756); - avl = remove_int(avl, 596); - avl = gpr_avl_add(avl, box(882), box(2221), nullptr); - avl = gpr_avl_add(avl, box(930), box(2222), nullptr); - avl = gpr_avl_add(avl, box(36), box(2223), nullptr); - avl = remove_int(avl, 742); - avl = gpr_avl_add(avl, box(539), box(2225), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(126), box(2232), nullptr); - avl = gpr_avl_add(avl, box(493), box(2233), nullptr); - avl = gpr_avl_add(avl, box(839), box(2234), nullptr); - avl = remove_int(avl, 774); - avl = gpr_avl_add(avl, box(337), box(2236), nullptr); - avl = remove_int(avl, 322); - avl = gpr_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 = gpr_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 = gpr_avl_add(avl, box(48), box(2248), nullptr); - avl = gpr_avl_add(avl, box(138), box(2249), nullptr); - avl = gpr_avl_add(avl, box(437), box(2250), nullptr); - avl = gpr_avl_add(avl, box(275), box(2251), nullptr); - avl = remove_int(avl, 520); - avl = gpr_avl_add(avl, box(1019), box(2253), nullptr); - avl = remove_int(avl, 955); - avl = gpr_avl_add(avl, box(270), box(2255), nullptr); - avl = remove_int(avl, 680); - avl = remove_int(avl, 698); - avl = gpr_avl_add(avl, box(735), box(2258), nullptr); - avl = gpr_avl_add(avl, box(400), box(2259), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(263), box(2261), nullptr); - avl = remove_int(avl, 704); - avl = gpr_avl_add(avl, box(757), box(2263), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 616); - avl = remove_int(avl, 784); - avl = gpr_avl_add(avl, box(382), box(2267), nullptr); - avl = gpr_avl_add(avl, box(464), box(2268), nullptr); - avl = gpr_avl_add(avl, box(817), box(2269), nullptr); - avl = remove_int(avl, 445); - avl = gpr_avl_add(avl, box(412), box(2271), nullptr); - avl = remove_int(avl, 525); - avl = gpr_avl_add(avl, box(299), box(2273), nullptr); - avl = gpr_avl_add(avl, box(464), box(2274), nullptr); - avl = gpr_avl_add(avl, box(715), box(2275), nullptr); - avl = remove_int(avl, 58); - avl = remove_int(avl, 218); - avl = gpr_avl_add(avl, box(961), box(2278), nullptr); - avl = gpr_avl_add(avl, box(491), box(2279), nullptr); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(762), box(2281), nullptr); - avl = remove_int(avl, 974); - avl = remove_int(avl, 887); - avl = gpr_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 = gpr_avl_add(avl, box(482), box(2289), nullptr); - avl = gpr_avl_add(avl, box(1021), box(2290), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 128); - avl = gpr_avl_add(avl, box(819), box(2293), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(272), box(2300), nullptr); - avl = gpr_avl_add(avl, box(474), box(2301), nullptr); - avl = gpr_avl_add(avl, box(719), box(2302), nullptr); - avl = gpr_avl_add(avl, box(236), box(2303), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(727), box(2305), nullptr); - avl = remove_int(avl, 892); - avl = remove_int(avl, 871); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(62), box(2309), nullptr); - avl = gpr_avl_add(avl, box(953), box(2310), nullptr); - avl = remove_int(avl, 701); - avl = gpr_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 = gpr_avl_add(avl, box(286), box(2317), nullptr); - avl = gpr_avl_add(avl, box(751), box(2318), nullptr); - avl = remove_int(avl, 525); - avl = gpr_avl_add(avl, box(217), box(2320), nullptr); - avl = remove_int(avl, 336); - avl = gpr_avl_add(avl, box(86), box(2322), nullptr); - avl = gpr_avl_add(avl, box(81), box(2323), nullptr); - avl = gpr_avl_add(avl, box(850), box(2324), nullptr); - avl = remove_int(avl, 872); - avl = gpr_avl_add(avl, box(402), box(2326), nullptr); - avl = gpr_avl_add(avl, box(54), box(2327), nullptr); - avl = gpr_avl_add(avl, box(980), box(2328), nullptr); - avl = gpr_avl_add(avl, box(845), box(2329), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 273); - avl = remove_int(avl, 879); - avl = gpr_avl_add(avl, box(354), box(2333), nullptr); - avl = gpr_avl_add(avl, box(58), box(2334), nullptr); - avl = gpr_avl_add(avl, box(127), box(2335), nullptr); - avl = remove_int(avl, 84); - avl = gpr_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 = gpr_avl_add(avl, box(887), box(2342), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 958); - avl = gpr_avl_add(avl, box(822), box(2345), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 747); - avl = gpr_avl_add(avl, box(631), box(2348), nullptr); - avl = gpr_avl_add(avl, box(442), box(2349), nullptr); - avl = remove_int(avl, 957); - avl = remove_int(avl, 964); - avl = gpr_avl_add(avl, box(10), box(2352), nullptr); - avl = remove_int(avl, 189); - avl = gpr_avl_add(avl, box(742), box(2354), nullptr); - avl = remove_int(avl, 108); - avl = gpr_avl_add(avl, box(1014), box(2356), nullptr); - avl = remove_int(avl, 266); - avl = remove_int(avl, 623); - avl = remove_int(avl, 697); - avl = gpr_avl_add(avl, box(180), box(2360), nullptr); - avl = remove_int(avl, 472); - avl = gpr_avl_add(avl, box(567), box(2362), nullptr); - avl = remove_int(avl, 1020); - avl = remove_int(avl, 273); - avl = gpr_avl_add(avl, box(864), box(2365), nullptr); - avl = gpr_avl_add(avl, box(1009), box(2366), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 81); - avl = gpr_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 = gpr_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 = gpr_avl_add(avl, box(443), box(2382), nullptr); - avl = gpr_avl_add(avl, box(925), box(2383), nullptr); - avl = remove_int(avl, 994); - avl = remove_int(avl, 324); - avl = gpr_avl_add(avl, box(291), box(2386), nullptr); - avl = remove_int(avl, 94); - avl = remove_int(avl, 795); - avl = remove_int(avl, 42); - avl = gpr_avl_add(avl, box(613), box(2390), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(980), box(2392), nullptr); - avl = remove_int(avl, 316); - avl = gpr_avl_add(avl, box(281), box(2394), nullptr); - avl = gpr_avl_add(avl, box(1006), box(2395), nullptr); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(108), box(2397), nullptr); - avl = gpr_avl_add(avl, box(918), box(2398), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 563); - avl = gpr_avl_add(avl, box(925), box(2401), nullptr); - avl = remove_int(avl, 448); - avl = remove_int(avl, 198); - avl = remove_int(avl, 1); - avl = gpr_avl_add(avl, box(160), box(2405), nullptr); - avl = remove_int(avl, 515); - avl = gpr_avl_add(avl, box(284), box(2407), nullptr); - avl = gpr_avl_add(avl, box(225), box(2408), nullptr); - avl = remove_int(avl, 304); - avl = gpr_avl_add(avl, box(714), box(2410), nullptr); - avl = gpr_avl_add(avl, box(708), box(2411), nullptr); - avl = gpr_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 = gpr_avl_add(avl, box(194), box(2417), nullptr); - avl = remove_int(avl, 280); - avl = remove_int(avl, 25); - avl = remove_int(avl, 633); - avl = gpr_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 = gpr_avl_add(avl, box(1008), box(2431), nullptr); - avl = remove_int(avl, 948); - avl = remove_int(avl, 74); - avl = remove_int(avl, 571); - avl = gpr_avl_add(avl, box(486), box(2435), nullptr); - avl = gpr_avl_add(avl, box(285), box(2436), nullptr); - avl = remove_int(avl, 304); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(758), box(2439), nullptr); - avl = gpr_avl_add(avl, box(776), box(2440), nullptr); - avl = remove_int(avl, 696); - avl = gpr_avl_add(avl, box(104), box(2442), nullptr); - avl = gpr_avl_add(avl, box(700), box(2443), nullptr); - avl = gpr_avl_add(avl, box(114), box(2444), nullptr); - avl = gpr_avl_add(avl, box(567), box(2445), nullptr); - avl = remove_int(avl, 620); - avl = gpr_avl_add(avl, box(270), box(2447), nullptr); - avl = remove_int(avl, 730); - avl = gpr_avl_add(avl, box(749), box(2449), nullptr); - avl = gpr_avl_add(avl, box(443), box(2450), nullptr); - avl = remove_int(avl, 457); - avl = gpr_avl_add(avl, box(571), box(2452), nullptr); - avl = gpr_avl_add(avl, box(626), box(2453), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 313); - - gpr_avl_unref(avl, nullptr); -} - -static void test_stress(int amount_of_stress) { - int added[1024]; - int i, j; - int deletions = 0; - gpr_avl avl; - - unsigned seed = (unsigned)time(nullptr); - - gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed); - - srand((unsigned)time(nullptr)); - avl = gpr_avl_create(&int_int_vtable); - - memset(added, 0, sizeof(added)); - - for (i = 1; deletions < amount_of_stress; i++) { - int idx = rand() % (int)GPR_ARRAY_SIZE(added); - GPR_ASSERT(i); - if (rand() < RAND_MAX / 2) { - added[idx] = i; - printf("avl = gpr_avl_add(avl, box(%d), box(%d), NULL); /* d=%d */\n", - idx, i, deletions); - avl = gpr_avl_add(avl, box(idx), box(i), nullptr); - } else { - deletions += (added[idx] != 0); - added[idx] = 0; - printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions); - avl = remove_int(avl, idx); - } - for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) { - if (added[j] != 0) { - check_get(avl, j, added[j]); - } else { - check_negget(avl, j); - } - } - } - - gpr_avl_unref(avl, nullptr); -} - -int main(int argc, char* argv[]) { - grpc_test_init(argc, argv); - - test_get(); - test_ll(); - test_lr(); - test_rr(); - test_rl(); - test_unbalanced(); - test_replace(); - test_remove(); - test_badcase1(); - test_badcase2(); - test_badcase3(); - test_stress(10); - - return 0; -} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3ff0baaacc..356bda0fd5 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -932,6 +932,7 @@ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ include/grpc/support/workaround_list.h \ src/core/ext/transport/inproc/inproc_transport.h \ +src/core/lib/avl/avl.h \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ @@ -951,7 +952,6 @@ src/core/lib/debug/stats.h \ src/core/lib/debug/stats_data.h \ src/core/lib/debug/trace.h \ src/core/lib/gpr/arena.h \ -src/core/lib/gpr/avl.h \ src/core/lib/gpr/env.h \ src/core/lib/gpr/fork.h \ src/core/lib/gpr/mpscq.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index c929475d50..9614a31c17 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1029,6 +1029,8 @@ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ src/core/lib/README.md \ +src/core/lib/avl/avl.cc \ +src/core/lib/avl/avl.h \ src/core/lib/backoff/backoff.cc \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/README.md \ @@ -1071,8 +1073,6 @@ src/core/lib/gpr/alloc.cc \ src/core/lib/gpr/arena.cc \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/atm.cc \ -src/core/lib/gpr/avl.cc \ -src/core/lib/gpr/avl.h \ src/core/lib/gpr/cmdline.cc \ src/core/lib/gpr/cpu_iphone.cc \ src/core/lib/gpr/cpu_linux.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c0a27cf665..8067748fed 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -82,6 +82,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "avl_test", + "src": [ + "test/core/avl/avl_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -587,21 +603,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_avl_test", - "src": [ - "test/core/gpr/avl_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -8171,7 +8172,6 @@ "src/core/lib/gpr/alloc.cc", "src/core/lib/gpr/arena.cc", "src/core/lib/gpr/atm.cc", - "src/core/lib/gpr/avl.cc", "src/core/lib/gpr/cmdline.cc", "src/core/lib/gpr/cpu_iphone.cc", "src/core/lib/gpr/cpu_linux.cc", @@ -8246,7 +8246,6 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "src/core/lib/gpr/arena.h", - "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", @@ -8295,7 +8294,6 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "src/core/lib/gpr/arena.h", - "src/core/lib/gpr/avl.h", "src/core/lib/gpr/env.h", "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", @@ -8398,6 +8396,7 @@ "language": "c", "name": "grpc_base", "src": [ + "src/core/lib/avl/avl.cc", "src/core/lib/backoff/backoff.cc", "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", @@ -8556,6 +8555,7 @@ "include/grpc/slice_buffer.h", "include/grpc/status.h", "include/grpc/support/workaround_list.h", + "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", @@ -8698,6 +8698,7 @@ "include/grpc/slice_buffer.h", "include/grpc/status.h", "include/grpc/support/workaround_list.h", + "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 87c0e260b3..077b4a8ed9 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -97,6 +97,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "avl_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, @@ -719,30 +743,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "gpr_avl_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, -- cgit v1.2.3 From 209f644f047ccf8ab13b207ebb145dadc0d37a42 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 8 Feb 2018 10:26:46 -0800 Subject: Convert resolver API to C++. --- BUILD | 8 +- CMakeLists.txt | 6 - Makefile | 6 - build.yaml | 1 - config.m4 | 1 - config.w32 | 1 - gRPC-Core.podspec | 1 - grpc.gemspec | 1 - grpc.gyp | 4 - package.xml | 1 - .../ext/filters/client_channel/client_channel.cc | 29 +- .../client_channel/client_channel_plugin.cc | 14 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 21 +- .../lb_policy/grpclb/grpclb_channel.cc | 5 +- .../lb_policy/grpclb/grpclb_channel.h | 2 +- .../lb_policy/grpclb/grpclb_channel_secure.cc | 5 +- src/core/ext/filters/client_channel/resolver.cc | 58 +-- src/core/ext/filters/client_channel/resolver.h | 153 ++++--- .../resolver/dns/c_ares/dns_resolver_ares.cc | 507 ++++++++++----------- .../resolver/dns/native/dns_resolver.cc | 449 +++++++++--------- .../client_channel/resolver/fake/fake_resolver.cc | 326 ++++++------- .../client_channel/resolver/fake/fake_resolver.h | 77 ++-- .../resolver/sockaddr/sockaddr_resolver.cc | 250 +++++----- .../ext/filters/client_channel/resolver_factory.cc | 40 -- .../ext/filters/client_channel/resolver_factory.h | 65 +-- .../filters/client_channel/resolver_registry.cc | 200 ++++---- .../ext/filters/client_channel/resolver_registry.h | 85 ++-- .../chttp2/client/insecure/channel_create.cc | 8 +- .../chttp2/client/secure/secure_channel_create.cc | 8 +- src/python/grpcio/grpc_core_dependencies.py | 1 - .../resolvers/dns_resolver_connectivity_test.cc | 44 +- .../resolvers/dns_resolver_cooldown_test.cc | 67 ++- .../client_channel/resolvers/dns_resolver_test.cc | 34 +- .../client_channel/resolvers/fake_resolver_test.cc | 113 +++-- .../resolvers/sockaddr_resolver_test.cc | 42 +- test/core/surface/channel_create_test.cc | 4 +- test/core/surface/secure_channel_create_test.cc | 4 +- test/cpp/client/client_channel_stress_test.cc | 13 +- test/cpp/end2end/client_lb_end2end_test.cc | 30 +- test/cpp/end2end/grpclb_end2end_test.cc | 18 +- test/cpp/grpclb/grpclb_test.cc | 22 +- test/cpp/naming/resolver_component_test.cc | 30 +- tools/doxygen/Doxyfile.core.internal | 1 - tools/run_tests/generated/sources_and_headers.json | 1 - 44 files changed, 1333 insertions(+), 1423 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver_factory.cc (limited to 'BUILD') diff --git a/BUILD b/BUILD index d68969b9be..2dd1fb34cf 100644 --- a/BUILD +++ b/BUILD @@ -950,7 +950,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/proxy_mapper.cc", "src/core/ext/filters/client_channel/proxy_mapper_registry.cc", "src/core/ext/filters/client_channel/resolver.cc", - "src/core/ext/filters/client_channel/resolver_factory.cc", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/retry_throttle.cc", "src/core/ext/filters/client_channel/subchannel.cc", @@ -980,10 +979,13 @@ grpc_cc_library( ], language = "c++", deps = [ - "grpc_base", - "grpc_deadline_filter", + "inlined_vector", + "orphanable", "ref_counted", "ref_counted_ptr", + "gpr_base", + "grpc_base", + "grpc_deadline_filter", ], ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d30fc60d9..06ebe64258 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1002,7 +1002,6 @@ add_library(grpc src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc @@ -1313,7 +1312,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc @@ -1605,7 +1603,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc @@ -1872,7 +1869,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc @@ -2155,7 +2151,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc @@ -2857,7 +2852,6 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/proxy_mapper.cc src/core/ext/filters/client_channel/proxy_mapper_registry.cc src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_factory.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc src/core/ext/filters/client_channel/subchannel.cc diff --git a/Makefile b/Makefile index 338be6c5a3..91d1cb8ff3 100644 --- a/Makefile +++ b/Makefile @@ -3231,7 +3231,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ @@ -3544,7 +3543,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ @@ -3837,7 +3835,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ @@ -4097,7 +4094,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ @@ -4360,7 +4356,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ @@ -5063,7 +5058,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ diff --git a/build.yaml b/build.yaml index 48412b5234..5ccb9109a6 100644 --- a/build.yaml +++ b/build.yaml @@ -471,7 +471,6 @@ filegroups: - src/core/ext/filters/client_channel/proxy_mapper.cc - src/core/ext/filters/client_channel/proxy_mapper_registry.cc - src/core/ext/filters/client_channel/resolver.cc - - src/core/ext/filters/client_channel/resolver_factory.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/subchannel.cc diff --git a/config.m4 b/config.m4 index 54340ba795..60257618d0 100644 --- a/config.m4 +++ b/config.m4 @@ -293,7 +293,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/proxy_mapper.cc \ src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/subchannel.cc \ diff --git a/config.w32 b/config.w32 index e50e7f3c66..b7754c1240 100644 --- a/config.w32 +++ b/config.w32 @@ -270,7 +270,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\proxy_mapper.cc " + "src\\core\\ext\\filters\\client_channel\\proxy_mapper_registry.cc " + "src\\core\\ext\\filters\\client_channel\\resolver.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver_factory.cc " + "src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " + "src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 28a6b01401..354b01682b 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -679,7 +679,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', diff --git a/grpc.gemspec b/grpc.gemspec index 44073873c9..91eb9108ff 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -609,7 +609,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/proxy_mapper.cc ) s.files += %w( src/core/ext/filters/client_channel/proxy_mapper_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver_factory.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) diff --git a/grpc.gyp b/grpc.gyp index 728f27b125..5a9a363a8e 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -434,7 +434,6 @@ 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', @@ -668,7 +667,6 @@ 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', @@ -880,7 +878,6 @@ 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', @@ -1107,7 +1104,6 @@ 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', diff --git a/package.xml b/package.xml index d2af8af4d0..1a403f3da1 100644 --- a/package.xml +++ b/package.xml @@ -616,7 +616,6 @@ - diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 6b93644430..a4dcd52839 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -165,7 +165,7 @@ struct external_connectivity_watcher; typedef struct client_channel_channel_data { /** resolver for this channel */ - grpc_resolver* resolver; + grpc_core::OrphanablePtr resolver; /** have we started resolving this channel */ bool started_resolving; /** is deadline checking enabled? */ @@ -300,8 +300,8 @@ static void start_resolving_locked(channel_data* chand) { GPR_ASSERT(!chand->started_resolving); chand->started_resolving = true; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next_locked(chand->resolver, &chand->resolver_result, - &chand->on_resolver_result_changed); + chand->resolver->NextLocked(&chand->resolver_result, + &chand->on_resolver_result_changed); } typedef struct { @@ -378,7 +378,7 @@ static void request_reresolution_locked(void* arg, grpc_error* error) { if (grpc_client_channel_trace.enabled()) { gpr_log(GPR_DEBUG, "chand=%p: started name re-resolving", chand); } - grpc_resolver_channel_saw_error_locked(chand->resolver); + chand->resolver->RequestReresolutionLocked(); // Give back the closure to the LB policy. grpc_lb_policy_set_reresolve_closure_locked(chand->lb_policy, &args->closure); } @@ -568,9 +568,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { if (grpc_client_channel_trace.enabled()) { gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand); } - grpc_resolver_shutdown_locked(chand->resolver); - GRPC_RESOLVER_UNREF(chand->resolver, "channel"); - chand->resolver = nullptr; + chand->resolver.reset(); } set_channel_connectivity_state_locked( chand, GRPC_CHANNEL_SHUTDOWN, @@ -606,8 +604,8 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { set_channel_connectivity_state_locked( chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver"); } - grpc_resolver_next_locked(chand->resolver, &chand->resolver_result, - &chand->on_resolver_result_changed); + chand->resolver->NextLocked(&chand->resolver_result, + &chand->on_resolver_result_changed); GRPC_ERROR_UNREF(state_error); } } @@ -648,9 +646,7 @@ static void start_transport_op_locked(void* arg, grpc_error* error_ignored) { set_channel_connectivity_state_locked( chand, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(op->disconnect_with_error), "disconnect"); - grpc_resolver_shutdown_locked(chand->resolver); - GRPC_RESOLVER_UNREF(chand->resolver, "channel"); - chand->resolver = nullptr; + chand->resolver.reset(); if (!chand->started_resolving) { grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures, GRPC_ERROR_REF(op->disconnect_with_error)); @@ -759,7 +755,7 @@ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem, grpc_proxy_mappers_map_name(arg->value.string, args->channel_args, &proxy_name, &new_args); // Instantiate resolver. - chand->resolver = grpc_resolver_create( + chand->resolver = grpc_core::ResolverRegistry::CreateResolver( proxy_name != nullptr ? proxy_name : arg->value.string, new_args != nullptr ? new_args : args->channel_args, chand->interested_parties, chand->combiner); @@ -774,9 +770,8 @@ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem, } static void shutdown_resolver_locked(void* arg, grpc_error* error) { - grpc_resolver* resolver = (grpc_resolver*)arg; - grpc_resolver_shutdown_locked(resolver); - GRPC_RESOLVER_UNREF(resolver, "channel"); + grpc_core::Resolver* resolver = static_cast(arg); + resolver->Orphan(); } /* Destructor for channel_data */ @@ -784,7 +779,7 @@ static void cc_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = (channel_data*)elem->channel_data; if (chand->resolver != nullptr) { GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver, + GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver.release(), grpc_combiner_scheduler(chand->combiner)), GRPC_ERROR_NONE); } diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index ea630d2917..d756d9cc05 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -49,14 +49,14 @@ static bool set_default_host_if_unset(grpc_channel_stack_builder* builder, return true; } } - char* default_authority = grpc_get_default_authority( - grpc_channel_stack_builder_get_target(builder)); - if (default_authority != nullptr) { + grpc_core::UniquePtr default_authority = + grpc_core::ResolverRegistry::GetDefaultAuthority( + grpc_channel_stack_builder_get_target(builder)); + if (default_authority.get() != nullptr) { grpc_arg arg = grpc_channel_arg_string_create( - (char*)GRPC_ARG_DEFAULT_AUTHORITY, default_authority); + (char*)GRPC_ARG_DEFAULT_AUTHORITY, default_authority.get()); grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1); grpc_channel_stack_builder_set_channel_arguments(builder, new_args); - gpr_free(default_authority); grpc_channel_args_destroy(new_args); } return true; @@ -64,7 +64,7 @@ static bool set_default_host_if_unset(grpc_channel_stack_builder* builder, void grpc_client_channel_init(void) { grpc_lb_policy_registry_init(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); grpc_retry_throttle_map_init(); grpc_proxy_mapper_registry_init(); grpc_register_http_proxy_mapper(); @@ -82,6 +82,6 @@ void grpc_client_channel_shutdown(void) { grpc_channel_init_shutdown(); grpc_proxy_mapper_registry_shutdown(); grpc_retry_throttle_map_shutdown(); - grpc_resolver_registry_shutdown(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); grpc_lb_policy_registry_shutdown(); } 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 5e24bdd4e7..ac47990478 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 @@ -108,6 +108,7 @@ #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -242,7 +243,8 @@ typedef struct glb_lb_policy { glb_lb_call_data* lb_calld; /** response generator to inject address updates into \a lb_channel */ - grpc_fake_resolver_response_generator* response_generator; + grpc_core::RefCountedPtr + response_generator; /** the RR policy to use of the backend servers returned by the LB server */ grpc_lb_policy* rr_policy; @@ -872,7 +874,7 @@ static int balancer_name_cmp_fn(void* a, void* b) { * - \a args: other args inherited from the grpclb policy. */ static grpc_channel_args* build_lb_channel_args( const grpc_lb_addresses* addresses, - grpc_fake_resolver_response_generator* response_generator, + grpc_core::FakeResolverResponseGenerator* response_generator, const grpc_channel_args* args) { size_t num_grpclb_addrs = 0; for (size_t i = 0; i < addresses->num_addresses; ++i) { @@ -941,7 +943,8 @@ static void glb_destroy(grpc_lb_policy* pol) { if (glb_policy->fallback_backend_addresses != nullptr) { grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses); } - grpc_fake_resolver_response_generator_unref(glb_policy->response_generator); + // TODO(roth): Remove this once the LB policy becomes a C++ object. + glb_policy->response_generator.reset(); grpc_subchannel_index_unref(); gpr_free(glb_policy); } @@ -1701,9 +1704,8 @@ static void glb_update_locked(grpc_lb_policy* policy, // Propagate updates to the LB channel (pick_first) through the fake // resolver. grpc_channel_args* lb_channel_args = build_lb_channel_args( - addresses, glb_policy->response_generator, args->args); - grpc_fake_resolver_response_generator_set_response( - glb_policy->response_generator, lb_channel_args); + addresses, glb_policy->response_generator.get(), args->args); + glb_policy->response_generator->SetResponse(lb_channel_args); grpc_channel_args_destroy(lb_channel_args); // Start watching the LB channel connectivity for connection, if not // already doing so. @@ -1858,17 +1860,16 @@ static grpc_lb_policy* glb_create(grpc_lb_policy_factory* factory, /* Create a client channel over them to communicate with a LB service */ glb_policy->response_generator = - grpc_fake_resolver_response_generator_create(); + grpc_core::MakeRefCounted(); grpc_channel_args* lb_channel_args = build_lb_channel_args( - addresses, glb_policy->response_generator, args->args); + addresses, glb_policy->response_generator.get(), args->args); char* uri_str; gpr_asprintf(&uri_str, "fake:///%s", glb_policy->server_name); glb_policy->lb_channel = grpc_lb_policy_grpclb_create_lb_channel( uri_str, args->client_channel_factory, lb_channel_args); /* Propagate initial resolution */ - grpc_fake_resolver_response_generator_set_response( - glb_policy->response_generator, lb_channel_args); + glb_policy->response_generator->SetResponse(lb_channel_args); grpc_channel_args_destroy(lb_channel_args); gpr_free(uri_str); if (glb_policy->lb_channel == nullptr) { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc index 1e7f34bdc7..013fb12aea 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc @@ -37,10 +37,11 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel( grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args( grpc_slice_hash_table* targets_info, - grpc_fake_resolver_response_generator* response_generator, + grpc_core::FakeResolverResponseGenerator* response_generator, const grpc_channel_args* args) { const grpc_arg to_add[] = { - grpc_fake_resolver_response_generator_arg(response_generator)}; + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator)}; /* We remove: * * - The channel arg for the LB policy name, since we want to use the default diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h index 56104b2ec0..2e34e3cab5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h @@ -37,7 +37,7 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel( grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args( grpc_slice_hash_table* targets_info, - grpc_fake_resolver_response_generator* response_generator, + grpc_core::FakeResolverResponseGenerator* response_generator, const grpc_channel_args* args); #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H \ 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 15233d371c..5e615addbf 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 @@ -63,11 +63,12 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel( grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args( grpc_slice_hash_table* targets_info, - grpc_fake_resolver_response_generator* response_generator, + grpc_core::FakeResolverResponseGenerator* response_generator, const grpc_channel_args* args) { const grpc_arg to_add[] = { grpc_lb_targets_info_create_channel_arg(targets_info), - grpc_fake_resolver_response_generator_arg(response_generator)}; + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator)}; /* We remove: * * - The channel arg for the LB policy name, since we want to use the default diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc index ff54e7179d..860c2eea1e 100644 --- a/src/core/ext/filters/client_channel/resolver.cc +++ b/src/core/ext/filters/client_channel/resolver.cc @@ -22,58 +22,12 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount(false, "resolver_refcount"); -void grpc_resolver_init(grpc_resolver* resolver, - const grpc_resolver_vtable* vtable, - grpc_combiner* combiner) { - resolver->vtable = vtable; - resolver->combiner = GRPC_COMBINER_REF(combiner, "resolver"); - gpr_ref_init(&resolver->refs, 1); -} +namespace grpc_core { -#ifndef NDEBUG -void grpc_resolver_ref(grpc_resolver* resolver, const char* file, int line, - const char* reason) { - if (grpc_trace_resolver_refcount.enabled()) { - gpr_atm old_refs = gpr_atm_no_barrier_load(&resolver->refs.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "RESOLVER:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", resolver, - old_refs, old_refs + 1, reason); - } -#else -void grpc_resolver_ref(grpc_resolver* resolver) { -#endif - gpr_ref(&resolver->refs); -} +Resolver::Resolver(grpc_combiner* combiner) + : InternallyRefCountedWithTracing(&grpc_trace_resolver_refcount), + combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {} -#ifndef NDEBUG -void grpc_resolver_unref(grpc_resolver* resolver, const char* file, int line, - const char* reason) { - if (grpc_trace_resolver_refcount.enabled()) { - gpr_atm old_refs = gpr_atm_no_barrier_load(&resolver->refs.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "RESOLVER:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", resolver, - old_refs, old_refs - 1, reason); - } -#else -void grpc_resolver_unref(grpc_resolver* resolver) { -#endif - if (gpr_unref(&resolver->refs)) { - grpc_combiner* combiner = resolver->combiner; - resolver->vtable->destroy(resolver); - GRPC_COMBINER_UNREF(combiner, "resolver"); - } -} +Resolver::~Resolver() { GRPC_COMBINER_UNREF(combiner_, "resolver"); } -void grpc_resolver_shutdown_locked(grpc_resolver* resolver) { - resolver->vtable->shutdown_locked(resolver); -} - -void grpc_resolver_channel_saw_error_locked(grpc_resolver* resolver) { - resolver->vtable->channel_saw_error_locked(resolver); -} - -void grpc_resolver_next_locked(grpc_resolver* resolver, - grpc_channel_args** result, - grpc_closure* on_complete) { - resolver->vtable->next_locked(resolver, result, on_complete); -} +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index f6a4af01d6..62fcb49a41 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -19,67 +19,110 @@ #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H -#include "src/core/ext/filters/client_channel/subchannel.h" -#include "src/core/lib/iomgr/iomgr.h" +#include -typedef struct grpc_resolver grpc_resolver; -typedef struct grpc_resolver_vtable grpc_resolver_vtable; +#include "src/core/lib/gprpp/abstract.h" +#include "src/core/lib/gprpp/orphanable.h" +#include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/iomgr.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount; -/** \a grpc_resolver provides \a grpc_channel_args objects to its caller */ -struct grpc_resolver { - const grpc_resolver_vtable* vtable; - gpr_refcount refs; - grpc_combiner* combiner; -}; +namespace grpc_core { + +/// Interface for name resolution. +/// +/// This interface is designed to support both push-based and pull-based +/// mechanisms. A push-based mechanism is one where the resolver will +/// subscribe to updates for a given name, and the name service will +/// proactively send new data to the resolver whenever the data associated +/// with the name changes. A pull-based mechanism is one where the resolver +/// needs to query the name service again to get updated information (e.g., +/// DNS). +/// +/// Note: All methods with a "Locked" suffix must be called from the +/// combiner passed to the constructor. +class Resolver : public InternallyRefCountedWithTracing { + public: + // Not copyable nor movable. + Resolver(const Resolver&) = delete; + Resolver& operator=(const Resolver&) = delete; + + /// Requests a callback when a new result becomes available. + /// When the new result is available, sets \a *result to the new result + /// and schedules \a on_complete for execution. + /// If resolution is fatally broken, sets \a *result to nullptr and + /// schedules \a on_complete with an error. + /// + /// Note that the client channel will almost always have a request + /// to \a NextLocked() pending. When it gets the callback, it will + /// process the new result and then immediately make another call to + /// \a NextLocked(). This allows push-based resolvers to provide new + /// data as soon as it becomes available. + virtual void NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) GRPC_ABSTRACT; + + /// Asks the resolver to obtain an updated resolver result, if + /// applicable. + /// + /// This is useful for pull-based implementations to decide when to + /// re-resolve. However, the implementation is not required to + /// re-resolve immediately upon receiving this call; it may instead + /// elect to delay based on some configured minimum time between + /// queries, to avoid hammering the name service with queries. + /// + /// For push-based implementations, this may be a no-op. + /// + /// If this causes new data to become available, then the currently + /// pending call to \a NextLocked() will return the new result. + /// + /// Note: Currently, all resolvers are required to return a new result + /// shortly after this method is called. For pull-based mechanisms, if + /// the implementation decides to delay querying the name service, it + /// should immediately return a new copy of the previously returned + /// result (and it can then return the updated data later, when it + /// actually does query the name service). For push-based mechanisms, + /// the implementation should immediately return a new copy of the + /// last-seen result. + /// TODO(roth): Remove this requirement once we fix pick_first to not + /// throw away unselected subchannels. + virtual void RequestReresolutionLocked() GRPC_ABSTRACT; + + void Orphan() override { + // Invoke ShutdownAndUnrefLocked() inside of the combiner. + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE(&Resolver::ShutdownAndUnrefLocked, this, + grpc_combiner_scheduler(combiner_)), + GRPC_ERROR_NONE); + } + + GRPC_ABSTRACT_BASE_CLASS + + protected: + /// Does NOT take ownership of the reference to \a combiner. + // TODO(roth): Once we have a C++-like interface for combiners, this + // API should change to take a RefCountedPtr<>, so that we always take + // ownership of a new ref. + explicit Resolver(grpc_combiner* combiner); + + virtual ~Resolver(); + + /// Shuts down the resolver. If there is a pending call to + /// NextLocked(), the callback will be scheduled with an error. + virtual void ShutdownLocked() GRPC_ABSTRACT; + + grpc_combiner* combiner() const { return combiner_; } + + private: + static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored) { + Resolver* resolver = static_cast(arg); + resolver->ShutdownLocked(); + resolver->Unref(); + } -struct grpc_resolver_vtable { - void (*destroy)(grpc_resolver* resolver); - void (*shutdown_locked)(grpc_resolver* resolver); - void (*channel_saw_error_locked)(grpc_resolver* resolver); - void (*next_locked)(grpc_resolver* resolver, grpc_channel_args** result, - grpc_closure* on_complete); + grpc_combiner* combiner_; }; -#ifndef NDEBUG -#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p), __FILE__, __LINE__, (r)) -#define GRPC_RESOLVER_UNREF(p, r) \ - grpc_resolver_unref((p), __FILE__, __LINE__, (r)) -void grpc_resolver_ref(grpc_resolver* policy, const char* file, int line, - const char* reason); -void grpc_resolver_unref(grpc_resolver* policy, const char* file, int line, - const char* reason); -#else -#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p)) -#define GRPC_RESOLVER_UNREF(p, r) grpc_resolver_unref((p)) -void grpc_resolver_ref(grpc_resolver* policy); -void grpc_resolver_unref(grpc_resolver* policy); -#endif - -void grpc_resolver_init(grpc_resolver* resolver, - const grpc_resolver_vtable* vtable, - grpc_combiner* combiner); - -void grpc_resolver_shutdown_locked(grpc_resolver* resolver); - -/** Notification that the channel has seen an error on some address. - Can be used as a hint that re-resolution is desirable soon. - - Must be called from the combiner passed as a resolver_arg at construction - time.*/ -void grpc_resolver_channel_saw_error_locked(grpc_resolver* resolver); - -/** Get the next result from the resolver. Expected to set \a *result with - new channel args and then schedule \a on_complete for execution. - - If resolution is fatally broken, set \a *result to NULL and - schedule \a on_complete. - - Must be called from the combiner passed as a resolver_arg at construction - time.*/ -void grpc_resolver_next_locked(grpc_resolver* resolver, - grpc_channel_args** result, - grpc_closure* on_complete); +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H */ 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 f2f25bc7c0..6e03ae447f 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 @@ -49,109 +49,168 @@ #define GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_DNS_RECONNECT_JITTER 0.2 -typedef struct { - /** base class: must be first */ - grpc_resolver base; - /** DNS server to use (if not system default) */ - char* dns_server; - /** name to resolve (usually the same as target_name) */ - char* name_to_resolve; - /** default port to use */ - char* default_port; - /** channel args. */ - grpc_channel_args* channel_args; - /** whether to request the service config */ - bool request_service_config; - /** pollset_set to drive the name resolution process */ - grpc_pollset_set* interested_parties; - - /** Closures used by the combiner */ - grpc_closure dns_ares_on_next_resolution_timer_closure; - grpc_closure dns_ares_on_resolved_closure; - - /** Combiner guarding the rest of the state */ - grpc_combiner* combiner; - /** are we currently resolving? */ - bool resolving; - /** the pending resolving request */ - grpc_ares_request* pending_request; - /** which version of the result have we published? */ - int published_version; - /** which version of the result is current? */ - int resolved_version; - /** pending next completion, or NULL */ - grpc_closure* next_completion; - /** target result address for next completion */ - grpc_channel_args** target_result; - /** current (fully resolved) result */ - grpc_channel_args* resolved_result; - /** next resolution timer */ - bool have_next_resolution_timer; - grpc_timer next_resolution_timer; - /** retry backoff state */ - grpc_core::ManualConstructor backoff; - /** min resolution period. Max one resolution will happen per period */ - grpc_millis min_time_between_resolutions; - /** when was the last resolution? -1 if no resolution has happened yet */ - grpc_millis last_resolution_timestamp; - /** currently resolving addresses */ - grpc_lb_addresses* lb_addresses; - /** currently resolving service config */ - char* service_config_json; -} ares_dns_resolver; - -static void dns_ares_destroy(grpc_resolver* r); - -static void dns_ares_start_resolving_locked(ares_dns_resolver* r); -static void dns_ares_maybe_start_resolving_locked(ares_dns_resolver* r); -static void dns_ares_maybe_finish_next_locked(ares_dns_resolver* r); - -static void dns_ares_shutdown_locked(grpc_resolver* r); -static void dns_ares_channel_saw_error_locked(grpc_resolver* r); -static void dns_ares_next_locked(grpc_resolver* r, - grpc_channel_args** target_result, - grpc_closure* on_complete); - -static const grpc_resolver_vtable dns_ares_resolver_vtable = { - dns_ares_destroy, dns_ares_shutdown_locked, - dns_ares_channel_saw_error_locked, dns_ares_next_locked}; - -static void dns_ares_shutdown_locked(grpc_resolver* resolver) { - ares_dns_resolver* r = (ares_dns_resolver*)resolver; - if (r->have_next_resolution_timer) { - grpc_timer_cancel(&r->next_resolution_timer); +namespace grpc_core { + +namespace { + +const char kDefaultPort[] = "https"; + +class AresDnsResolver : public Resolver { + public: + explicit AresDnsResolver(const ResolverArgs& args); + + void NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) override; + + void RequestReresolutionLocked() override; + + void ShutdownLocked() override; + + private: + virtual ~AresDnsResolver(); + + void MaybeStartResolvingLocked(); + void StartResolvingLocked(); + void MaybeFinishNextLocked(); + + static void OnNextResolutionLocked(void* arg, grpc_error* error); + static void OnResolvedLocked(void* arg, grpc_error* error); + + /// DNS server to use (if not system default) + char* dns_server_; + /// name to resolve (usually the same as target_name) + char* name_to_resolve_; + /// channel args + grpc_channel_args* channel_args_; + /// whether to request the service config + bool request_service_config_; + /// pollset_set to drive the name resolution process + grpc_pollset_set* interested_parties_; + /// closures used by the combiner + grpc_closure on_next_resolution_; + grpc_closure on_resolved_; + /// are we currently resolving? + bool resolving_ = false; + /// the pending resolving request + grpc_ares_request* pending_request_ = nullptr; + /// which version of the result have we published? + int published_version_ = 0; + /// which version of the result is current? + int resolved_version_ = 0; + /// pending next completion, or NULL + grpc_closure* next_completion_ = nullptr; + /// target result address for next completion + grpc_channel_args** target_result_ = nullptr; + /// current (fully resolved) result + grpc_channel_args* resolved_result_ = nullptr; + /// next resolution timer + bool have_next_resolution_timer_ = false; + grpc_timer next_resolution_timer_; + /// min interval between DNS requests + grpc_millis min_time_between_resolutions_; + /// timestamp of last DNS request + grpc_millis last_resolution_timestamp_ = -1; + /// retry backoff state + BackOff backoff_; + /// currently resolving addresses + grpc_lb_addresses* lb_addresses_ = nullptr; + /// currently resolving service config + char* service_config_json_ = nullptr; +}; + +AresDnsResolver::AresDnsResolver(const ResolverArgs& args) + : Resolver(args.combiner), + backoff_( + BackOff::Options() + .set_initial_backoff(GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * + 1000) + .set_multiplier(GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER) + .set_jitter(GRPC_DNS_RECONNECT_JITTER) + .set_max_backoff(GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) { + // Get name to resolve from URI path. + const char* path = args.uri->path; + if (path[0] == '/') ++path; + name_to_resolve_ = gpr_strdup(path); + // Get DNS server from URI authority. + if (0 != strcmp(args.uri->authority, "")) { + 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}); + interested_parties_ = grpc_pollset_set_create(); + if (args.pollset_set != nullptr) { + grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set); + } + GRPC_CLOSURE_INIT(&on_next_resolution_, OnNextResolutionLocked, this, + grpc_combiner_scheduler(combiner())); + GRPC_CLOSURE_INIT(&on_resolved_, OnResolvedLocked, this, + grpc_combiner_scheduler(combiner())); +} + +AresDnsResolver::~AresDnsResolver() { + gpr_log(GPR_DEBUG, "destroying AresDnsResolver"); + if (resolved_result_ != nullptr) { + grpc_channel_args_destroy(resolved_result_); } - if (r->pending_request != nullptr) { - grpc_cancel_ares_request(r->pending_request); + grpc_pollset_set_destroy(interested_parties_); + gpr_free(dns_server_); + gpr_free(name_to_resolve_); + grpc_channel_args_destroy(channel_args_); +} + +void AresDnsResolver::NextLocked(grpc_channel_args** target_result, + grpc_closure* on_complete) { + gpr_log(GPR_DEBUG, "AresDnsResolver::NextLocked() is called."); + GPR_ASSERT(next_completion_ == nullptr); + next_completion_ = on_complete; + target_result_ = target_result; + if (resolved_version_ == 0 && !resolving_) { + MaybeStartResolvingLocked(); + } else { + MaybeFinishNextLocked(); } - if (r->next_completion != nullptr) { - *r->target_result = nullptr; - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Resolver Shutdown")); - r->next_completion = nullptr; +} + +void AresDnsResolver::RequestReresolutionLocked() { + if (!resolving_) { + MaybeStartResolvingLocked(); } } -static void dns_ares_channel_saw_error_locked(grpc_resolver* resolver) { - ares_dns_resolver* r = (ares_dns_resolver*)resolver; - if (!r->resolving) { - dns_ares_maybe_start_resolving_locked(r); +void AresDnsResolver::ShutdownLocked() { + if (have_next_resolution_timer_) { + grpc_timer_cancel(&next_resolution_timer_); + } + if (pending_request_ != nullptr) { + grpc_cancel_ares_request(pending_request_); + } + if (next_completion_ != nullptr) { + *target_result_ = nullptr; + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Resolver Shutdown")); + next_completion_ = nullptr; } } -static void dns_ares_on_next_resolution_timer_locked(void* arg, - grpc_error* error) { - ares_dns_resolver* r = (ares_dns_resolver*)arg; - r->have_next_resolution_timer = false; +void AresDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) { + AresDnsResolver* r = static_cast(arg); + r->have_next_resolution_timer_ = false; if (error == GRPC_ERROR_NONE) { - if (!r->resolving) { - dns_ares_start_resolving_locked(r); + if (!r->resolving_) { + r->StartResolvingLocked(); } } - GRPC_RESOLVER_UNREF(&r->base, "next_resolution_timer"); + r->Unref(DEBUG_LOCATION, "next_resolution_timer"); } -static bool value_in_json_array(grpc_json* array, const char* value) { +bool ValueInJsonArray(grpc_json* array, const char* value) { for (grpc_json* entry = array->child; entry != nullptr; entry = entry->next) { if (entry->type == GRPC_JSON_STRING && strcmp(entry->value, value) == 0) { return true; @@ -160,7 +219,7 @@ static bool value_in_json_array(grpc_json* array, const char* value) { return false; } -static char* choose_service_config(char* service_config_choice_json) { +char* ChooseServiceConfig(char* service_config_choice_json) { grpc_json* choices_json = grpc_json_parse_string(service_config_choice_json); if (choices_json == nullptr || choices_json->type != GRPC_JSON_ARRAY) { gpr_log(GPR_ERROR, "cannot parse service config JSON string"); @@ -178,8 +237,7 @@ static char* choose_service_config(char* service_config_choice_json) { field = field->next) { // Check client language, if specified. if (strcmp(field->key, "clientLanguage") == 0) { - if (field->type != GRPC_JSON_ARRAY || - !value_in_json_array(field, "c++")) { + if (field->type != GRPC_JSON_ARRAY || !ValueInJsonArray(field, "c++")) { service_config_json = nullptr; break; } @@ -188,7 +246,7 @@ static char* choose_service_config(char* service_config_choice_json) { if (strcmp(field->key, "clientHostname") == 0) { char* hostname = grpc_gethostname(); if (hostname == nullptr || field->type != GRPC_JSON_ARRAY || - !value_in_json_array(field, hostname)) { + !ValueInJsonArray(field, hostname)) { service_config_json = nullptr; break; } @@ -223,24 +281,24 @@ static char* choose_service_config(char* service_config_choice_json) { return service_config; } -static void dns_ares_on_resolved_locked(void* arg, grpc_error* error) { - ares_dns_resolver* r = (ares_dns_resolver*)arg; +void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { + AresDnsResolver* r = static_cast(arg); grpc_channel_args* result = nullptr; - GPR_ASSERT(r->resolving); - r->resolving = false; - r->pending_request = nullptr; - if (r->lb_addresses != nullptr) { + GPR_ASSERT(r->resolving_); + r->resolving_ = false; + r->pending_request_ = nullptr; + if (r->lb_addresses_ != nullptr) { static const char* args_to_remove[2]; size_t num_args_to_remove = 0; grpc_arg new_args[3]; size_t num_args_to_add = 0; new_args[num_args_to_add++] = - grpc_lb_addresses_create_channel_arg(r->lb_addresses); + grpc_lb_addresses_create_channel_arg(r->lb_addresses_); grpc_service_config* service_config = nullptr; char* service_config_string = nullptr; - if (r->service_config_json != nullptr) { - service_config_string = choose_service_config(r->service_config_json); - gpr_free(r->service_config_json); + if (r->service_config_json_ != nullptr) { + service_config_string = ChooseServiceConfig(r->service_config_json_); + gpr_free(r->service_config_json_); if (service_config_string != nullptr) { gpr_log(GPR_INFO, "selected service config choice: %s", service_config_string); @@ -260,221 +318,150 @@ static void dns_ares_on_resolved_locked(void* arg, grpc_error* error) { } } result = grpc_channel_args_copy_and_add_and_remove( - r->channel_args, args_to_remove, num_args_to_remove, new_args, + r->channel_args_, args_to_remove, num_args_to_remove, new_args, num_args_to_add); if (service_config != nullptr) grpc_service_config_destroy(service_config); gpr_free(service_config_string); - grpc_lb_addresses_destroy(r->lb_addresses); + grpc_lb_addresses_destroy(r->lb_addresses_); // Reset backoff state so that we start from the beginning when the // next request gets triggered. - r->backoff->Reset(); + r->backoff_.Reset(); } else { const char* msg = grpc_error_string(error); gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg); - grpc_millis next_try = r->backoff->NextAttemptTime(); - grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now(); + grpc_millis next_try = r->backoff_.NextAttemptTime(); + grpc_millis timeout = next_try - ExecCtx::Get()->Now(); gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", grpc_error_string(error)); - GPR_ASSERT(!r->have_next_resolution_timer); - r->have_next_resolution_timer = true; - GRPC_RESOLVER_REF(&r->base, "next_resolution_timer"); + GPR_ASSERT(!r->have_next_resolution_timer_); + r->have_next_resolution_timer_ = true; + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = r->Ref(DEBUG_LOCATION, "retry-timer"); + self.release(); if (timeout > 0) { gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout); } else { gpr_log(GPR_DEBUG, "retrying immediately"); } - grpc_timer_init(&r->next_resolution_timer, next_try, - &r->dns_ares_on_next_resolution_timer_closure); + grpc_timer_init(&r->next_resolution_timer_, next_try, + &r->on_next_resolution_); } - if (r->resolved_result != nullptr) { - grpc_channel_args_destroy(r->resolved_result); - } - r->resolved_result = result; - r->last_resolution_timestamp = grpc_core::ExecCtx::Get()->Now(); - r->resolved_version++; - dns_ares_maybe_finish_next_locked(r); - GRPC_RESOLVER_UNREF(&r->base, "dns-resolving"); -} - -static void dns_ares_next_locked(grpc_resolver* resolver, - grpc_channel_args** target_result, - grpc_closure* on_complete) { - gpr_log(GPR_DEBUG, "dns_ares_next is called."); - ares_dns_resolver* r = (ares_dns_resolver*)resolver; - GPR_ASSERT(!r->next_completion); - r->next_completion = on_complete; - r->target_result = target_result; - if (r->resolved_version == 0 && !r->resolving) { - dns_ares_maybe_start_resolving_locked(r); - } else { - dns_ares_maybe_finish_next_locked(r); + if (r->resolved_result_ != nullptr) { + grpc_channel_args_destroy(r->resolved_result_); } + r->resolved_result_ = result; + ++r->resolved_version_; + r->MaybeFinishNextLocked(); + r->Unref(DEBUG_LOCATION, "dns-resolving"); } -static void dns_ares_start_resolving_locked(ares_dns_resolver* r) { - GRPC_RESOLVER_REF(&r->base, "dns-resolving"); - GPR_ASSERT(!r->resolving); - r->resolving = true; - r->lb_addresses = nullptr; - r->service_config_json = nullptr; - r->pending_request = grpc_dns_lookup_ares( - r->dns_server, r->name_to_resolve, r->default_port, r->interested_parties, - &r->dns_ares_on_resolved_closure, &r->lb_addresses, - true /* check_grpclb */, - r->request_service_config ? &r->service_config_json : nullptr); -} - -static void dns_ares_maybe_finish_next_locked(ares_dns_resolver* r) { - if (r->next_completion != nullptr && - r->resolved_version != r->published_version) { - *r->target_result = r->resolved_result == nullptr - ? nullptr - : grpc_channel_args_copy(r->resolved_result); - gpr_log(GPR_DEBUG, "dns_ares_maybe_finish_next_locked"); - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE); - r->next_completion = nullptr; - r->published_version = r->resolved_version; - } -} - -static void dns_ares_maybe_start_resolving_locked(ares_dns_resolver* r) { - if (r->last_resolution_timestamp >= 0) { +void AresDnsResolver::MaybeStartResolvingLocked() { + if (last_resolution_timestamp_ >= 0) { const grpc_millis earliest_next_resolution = - r->last_resolution_timestamp + r->min_time_between_resolutions; + last_resolution_timestamp_ + min_time_between_resolutions_; const grpc_millis ms_until_next_resolution = earliest_next_resolution - grpc_core::ExecCtx::Get()->Now(); if (ms_until_next_resolution > 0) { const grpc_millis last_resolution_ago = - grpc_core::ExecCtx::Get()->Now() - r->last_resolution_timestamp; + grpc_core::ExecCtx::Get()->Now() - last_resolution_timestamp_; gpr_log(GPR_DEBUG, "In cooldown from last resolution (from %" PRIdPTR " ms ago). Will resolve again in %" PRIdPTR " ms", last_resolution_ago, ms_until_next_resolution); - if (!r->have_next_resolution_timer) { - r->have_next_resolution_timer = true; - GRPC_RESOLVER_REF(&r->base, "next_resolution_timer_cooldown"); - grpc_timer_init(&r->next_resolution_timer, ms_until_next_resolution, - &r->dns_ares_on_next_resolution_timer_closure); + if (!have_next_resolution_timer_) { + have_next_resolution_timer_ = true; + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = + Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown"); + self.release(); + grpc_timer_init(&next_resolution_timer_, ms_until_next_resolution, + &on_next_resolution_); } // TODO(dgq): remove the following two lines once Pick First stops // discarding subchannels after selecting. - ++r->resolved_version; - dns_ares_maybe_finish_next_locked(r); + ++resolved_version_; + MaybeFinishNextLocked(); return; } } - dns_ares_start_resolving_locked(r); + StartResolvingLocked(); } -static void dns_ares_destroy(grpc_resolver* gr) { - gpr_log(GPR_DEBUG, "dns_ares_destroy"); - ares_dns_resolver* r = (ares_dns_resolver*)gr; - if (r->resolved_result != nullptr) { - grpc_channel_args_destroy(r->resolved_result); - } - grpc_pollset_set_destroy(r->interested_parties); - gpr_free(r->dns_server); - gpr_free(r->name_to_resolve); - gpr_free(r->default_port); - grpc_channel_args_destroy(r->channel_args); - gpr_free(r); +void AresDnsResolver::StartResolvingLocked() { + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = Ref(DEBUG_LOCATION, "dns-resolving"); + self.release(); + GPR_ASSERT(!resolving_); + resolving_ = true; + lb_addresses_ = nullptr; + service_config_json_ = nullptr; + pending_request_ = grpc_dns_lookup_ares( + dns_server_, name_to_resolve_, kDefaultPort, interested_parties_, + &on_resolved_, &lb_addresses_, true /* check_grpclb */, + request_service_config_ ? &service_config_json_ : nullptr); + last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now(); } -static grpc_resolver* dns_ares_create(grpc_resolver_args* args, - const char* default_port) { - /* Get name from args. */ - const char* path = args->uri->path; - if (path[0] == '/') ++path; - /* Create resolver. */ - ares_dns_resolver* r = - (ares_dns_resolver*)gpr_zalloc(sizeof(ares_dns_resolver)); - grpc_resolver_init(&r->base, &dns_ares_resolver_vtable, args->combiner); - if (0 != strcmp(args->uri->authority, "")) { - r->dns_server = gpr_strdup(args->uri->authority); - } - r->name_to_resolve = gpr_strdup(path); - r->default_port = gpr_strdup(default_port); - r->channel_args = grpc_channel_args_copy(args->args); - const grpc_arg* arg = grpc_channel_args_find( - r->channel_args, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION); - r->request_service_config = !grpc_channel_arg_get_integer( - arg, (grpc_integer_options){false, false, true}); - r->interested_parties = grpc_pollset_set_create(); - if (args->pollset_set != nullptr) { - grpc_pollset_set_add_pollset_set(r->interested_parties, args->pollset_set); +void AresDnsResolver::MaybeFinishNextLocked() { + if (next_completion_ != nullptr && resolved_version_ != published_version_) { + *target_result_ = resolved_result_ == nullptr + ? nullptr + : grpc_channel_args_copy(resolved_result_); + gpr_log(GPR_DEBUG, "AresDnsResolver::MaybeFinishNextLocked()"); + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE); + next_completion_ = nullptr; + published_version_ = resolved_version_; } - grpc_core::BackOff::Options backoff_options; - backoff_options - .set_initial_backoff(GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000) - .set_multiplier(GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER) - .set_jitter(GRPC_DNS_RECONNECT_JITTER) - .set_max_backoff(GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); - r->backoff.Init(grpc_core::BackOff(backoff_options)); - GRPC_CLOSURE_INIT(&r->dns_ares_on_next_resolution_timer_closure, - dns_ares_on_next_resolution_timer_locked, r, - grpc_combiner_scheduler(r->base.combiner)); - GRPC_CLOSURE_INIT(&r->dns_ares_on_resolved_closure, - dns_ares_on_resolved_locked, r, - grpc_combiner_scheduler(r->base.combiner)); - const grpc_arg* period_arg = grpc_channel_args_find( - args->args, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); - r->min_time_between_resolutions = - grpc_channel_arg_get_integer(period_arg, {1000, 0, INT_MAX}); - r->last_resolution_timestamp = -1; - return &r->base; } -/* - * FACTORY - */ - -static void dns_ares_factory_ref(grpc_resolver_factory* factory) {} +// +// Factory +// -static void dns_ares_factory_unref(grpc_resolver_factory* factory) {} - -static grpc_resolver* dns_factory_create_resolver( - grpc_resolver_factory* factory, grpc_resolver_args* args) { - return dns_ares_create(args, "https"); -} +class AresDnsResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + return OrphanablePtr(New(args)); + } -static char* dns_ares_factory_get_default_host_name( - grpc_resolver_factory* factory, grpc_uri* uri) { - const char* path = uri->path; - if (path[0] == '/') ++path; - return gpr_strdup(path); -} + const char* scheme() const override { return "dns"; } +}; -static const grpc_resolver_factory_vtable dns_ares_factory_vtable = { - dns_ares_factory_ref, dns_ares_factory_unref, dns_factory_create_resolver, - dns_ares_factory_get_default_host_name, "dns"}; -static grpc_resolver_factory dns_resolver_factory = {&dns_ares_factory_vtable}; +} // namespace -static grpc_resolver_factory* dns_ares_resolver_factory_create() { - return &dns_resolver_factory; -} +} // namespace grpc_core -void grpc_resolver_dns_ares_init(void) { - char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); +void grpc_resolver_dns_ares_init() { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); /* TODO(zyc): Turn on c-ares based resolver by default after the address sorter and the CNAME support are added. */ - if (resolver != nullptr && gpr_stricmp(resolver, "ares") == 0) { + if (resolver_env != nullptr && gpr_stricmp(resolver_env, "ares") == 0) { grpc_error* error = grpc_ares_init(); if (error != GRPC_ERROR_NONE) { GRPC_LOG_IF_ERROR("ares_library_init() failed", error); return; } grpc_resolve_address = grpc_resolve_address_ares; - grpc_register_resolver_type(dns_ares_resolver_factory_create()); + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); } - gpr_free(resolver); + gpr_free(resolver_env); } -void grpc_resolver_dns_ares_shutdown(void) { - char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver != nullptr && gpr_stricmp(resolver, "ares") == 0) { +void grpc_resolver_dns_ares_shutdown() { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver_env != nullptr && gpr_stricmp(resolver_env, "ares") == 0) { grpc_ares_cleanup(); } - gpr_free(resolver); + gpr_free(resolver_env); } #else /* GRPC_ARES == 1 && !defined(GRPC_UV) */ 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 478810d263..fbab136421 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 @@ -43,301 +43,298 @@ #define GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_DNS_RECONNECT_JITTER 0.2 -typedef struct { - /** base class: must be first */ - grpc_resolver base; - /** name to resolve */ - char* name_to_resolve; - /** default port to use */ - char* default_port; - /** channel args. */ - grpc_channel_args* channel_args; - /** pollset_set to drive the name resolution process */ - grpc_pollset_set* interested_parties; - - /** are we currently resolving? */ - bool resolving; - /** which version of the result have we published? */ - int published_version; - /** which version of the result is current? */ - int resolved_version; - /** pending next completion, or NULL */ - grpc_closure* next_completion; - /** target result address for next completion */ - grpc_channel_args** target_result; - /** current (fully resolved) result */ - grpc_channel_args* resolved_result; - /** next resolution timer */ - bool have_next_resolution_timer; - grpc_timer next_resolution_timer; - grpc_closure next_resolution_closure; - /** retry backoff state */ - grpc_core::ManualConstructor backoff; - /** min resolution period. Max one resolution will happen per period */ - grpc_millis min_time_between_resolutions; - /** when was the last resolution? -1 if no resolution has happened yet */ - grpc_millis last_resolution_timestamp; - /** currently resolving addresses */ - grpc_resolved_addresses* addresses; -} dns_resolver; - -static void dns_destroy(grpc_resolver* r); - -static void dns_start_resolving_locked(dns_resolver* r); -static void maybe_start_resolving_locked(dns_resolver* r); -static void dns_maybe_finish_next_locked(dns_resolver* r); - -static void dns_shutdown_locked(grpc_resolver* r); -static void dns_channel_saw_error_locked(grpc_resolver* r); -static void dns_next_locked(grpc_resolver* r, grpc_channel_args** target_result, - grpc_closure* on_complete); - -static const grpc_resolver_vtable dns_resolver_vtable = { - dns_destroy, dns_shutdown_locked, dns_channel_saw_error_locked, - dns_next_locked}; - -static void dns_shutdown_locked(grpc_resolver* resolver) { - dns_resolver* r = (dns_resolver*)resolver; - if (r->have_next_resolution_timer) { - grpc_timer_cancel(&r->next_resolution_timer); - } - if (r->next_completion != nullptr) { - *r->target_result = nullptr; - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Resolver Shutdown")); - r->next_completion = nullptr; +namespace grpc_core { + +namespace { + +const char kDefaultPort[] = "https"; + +class NativeDnsResolver : public Resolver { + public: + explicit NativeDnsResolver(const ResolverArgs& args); + + void NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) override; + + void RequestReresolutionLocked() override; + + void ShutdownLocked() override; + + private: + virtual ~NativeDnsResolver(); + + void MaybeStartResolvingLocked(); + void StartResolvingLocked(); + void MaybeFinishNextLocked(); + + static void OnNextResolutionLocked(void* arg, grpc_error* error); + static void OnResolvedLocked(void* arg, grpc_error* error); + + /// name to resolve + char* name_to_resolve_ = nullptr; + /// channel args + grpc_channel_args* channel_args_ = nullptr; + /// pollset_set to drive the name resolution process + grpc_pollset_set* interested_parties_ = nullptr; + /// are we currently resolving? + bool resolving_ = false; + grpc_closure on_resolved_; + /// which version of the result have we published? + int published_version_ = 0; + /// which version of the result is current? + int resolved_version_ = 0; + /// pending next completion, or nullptr + grpc_closure* next_completion_ = nullptr; + /// target result address for next completion + grpc_channel_args** target_result_ = nullptr; + /// current (fully resolved) result + grpc_channel_args* resolved_result_ = nullptr; + /// next resolution timer + bool have_next_resolution_timer_ = false; + grpc_timer next_resolution_timer_; + grpc_closure on_next_resolution_; + /// min time between DNS requests + grpc_millis min_time_between_resolutions_; + /// timestamp of last DNS request + grpc_millis last_resolution_timestamp_ = -1; + /// retry backoff state + BackOff backoff_; + /// currently resolving addresses + grpc_resolved_addresses* addresses_ = nullptr; +}; + +NativeDnsResolver::NativeDnsResolver(const ResolverArgs& args) + : Resolver(args.combiner), + backoff_( + BackOff::Options() + .set_initial_backoff(GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * + 1000) + .set_multiplier(GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER) + .set_jitter(GRPC_DNS_RECONNECT_JITTER) + .set_max_backoff(GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) { + char* path = args.uri->path; + 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}); + interested_parties_ = grpc_pollset_set_create(); + if (args.pollset_set != nullptr) { + grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set); } + GRPC_CLOSURE_INIT(&on_next_resolution_, + NativeDnsResolver::OnNextResolutionLocked, this, + grpc_combiner_scheduler(args.combiner)); + GRPC_CLOSURE_INIT(&on_resolved_, NativeDnsResolver::OnResolvedLocked, this, + grpc_combiner_scheduler(args.combiner)); } -static void dns_channel_saw_error_locked(grpc_resolver* resolver) { - dns_resolver* r = (dns_resolver*)resolver; - if (!r->resolving) { - maybe_start_resolving_locked(r); +NativeDnsResolver::~NativeDnsResolver() { + if (resolved_result_ != nullptr) { + grpc_channel_args_destroy(resolved_result_); } + grpc_pollset_set_destroy(interested_parties_); + gpr_free(name_to_resolve_); + grpc_channel_args_destroy(channel_args_); } -static void dns_next_locked(grpc_resolver* resolver, - grpc_channel_args** target_result, - grpc_closure* on_complete) { - dns_resolver* r = (dns_resolver*)resolver; - GPR_ASSERT(!r->next_completion); - r->next_completion = on_complete; - r->target_result = target_result; - if (r->resolved_version == 0 && !r->resolving) { - maybe_start_resolving_locked(r); +void NativeDnsResolver::NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) { + GPR_ASSERT(next_completion_ == nullptr); + next_completion_ = on_complete; + target_result_ = result; + if (resolved_version_ == 0 && !resolving_) { + MaybeStartResolvingLocked(); } else { - dns_maybe_finish_next_locked(r); + MaybeFinishNextLocked(); + } +} + +void NativeDnsResolver::RequestReresolutionLocked() { + if (!resolving_) { + MaybeStartResolvingLocked(); + } +} + +void NativeDnsResolver::ShutdownLocked() { + if (have_next_resolution_timer_) { + grpc_timer_cancel(&next_resolution_timer_); + } + if (next_completion_ != nullptr) { + *target_result_ = nullptr; + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Resolver Shutdown")); + next_completion_ = nullptr; } } -static void dns_on_next_resolution_timer_locked(void* arg, grpc_error* error) { - dns_resolver* r = (dns_resolver*)arg; - r->have_next_resolution_timer = false; - if (error == GRPC_ERROR_NONE && !r->resolving) { - dns_start_resolving_locked(r); +void NativeDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) { + NativeDnsResolver* r = static_cast(arg); + r->have_next_resolution_timer_ = false; + if (error == GRPC_ERROR_NONE && !r->resolving_) { + r->StartResolvingLocked(); } - GRPC_RESOLVER_UNREF(&r->base, "next_resolution_timer"); + r->Unref(DEBUG_LOCATION, "retry-timer"); } -static void dns_on_resolved_locked(void* arg, grpc_error* error) { - dns_resolver* r = (dns_resolver*)arg; +void NativeDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { + NativeDnsResolver* r = static_cast(arg); grpc_channel_args* result = nullptr; - GPR_ASSERT(r->resolving); - r->resolving = false; + GPR_ASSERT(r->resolving_); + r->resolving_ = false; GRPC_ERROR_REF(error); - error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, - grpc_slice_from_copied_string(r->name_to_resolve)); - if (r->addresses != nullptr) { + error = + grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, + grpc_slice_from_copied_string(r->name_to_resolve_)); + if (r->addresses_ != nullptr) { grpc_lb_addresses* addresses = grpc_lb_addresses_create( - r->addresses->naddrs, nullptr /* user_data_vtable */); - for (size_t i = 0; i < r->addresses->naddrs; ++i) { + r->addresses_->naddrs, nullptr /* user_data_vtable */); + for (size_t i = 0; i < r->addresses_->naddrs; ++i) { grpc_lb_addresses_set_address( - addresses, i, &r->addresses->addrs[i].addr, - r->addresses->addrs[i].len, false /* is_balancer */, + addresses, i, &r->addresses_->addrs[i].addr, + r->addresses_->addrs[i].len, false /* is_balancer */, nullptr /* balancer_name */, nullptr /* user_data */); } grpc_arg new_arg = grpc_lb_addresses_create_channel_arg(addresses); - result = grpc_channel_args_copy_and_add(r->channel_args, &new_arg, 1); - grpc_resolved_addresses_destroy(r->addresses); + result = grpc_channel_args_copy_and_add(r->channel_args_, &new_arg, 1); + grpc_resolved_addresses_destroy(r->addresses_); grpc_lb_addresses_destroy(addresses); // Reset backoff state so that we start from the beginning when the // next request gets triggered. - r->backoff->Reset(); + r->backoff_.Reset(); } else { - grpc_millis next_try = r->backoff->NextAttemptTime(); - grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now(); + grpc_millis next_try = r->backoff_.NextAttemptTime(); + grpc_millis timeout = next_try - ExecCtx::Get()->Now(); gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", grpc_error_string(error)); - GPR_ASSERT(!r->have_next_resolution_timer); - r->have_next_resolution_timer = true; - GRPC_RESOLVER_REF(&r->base, "next_resolution_timer"); + GPR_ASSERT(!r->have_next_resolution_timer_); + r->have_next_resolution_timer_ = true; + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = + r->Ref(DEBUG_LOCATION, "next_resolution_timer"); + self.release(); if (timeout > 0) { gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout); } else { gpr_log(GPR_DEBUG, "retrying immediately"); } - grpc_timer_init(&r->next_resolution_timer, next_try, - &r->next_resolution_closure); + grpc_timer_init(&r->next_resolution_timer_, next_try, + &r->on_next_resolution_); } - if (r->resolved_result != nullptr) { - grpc_channel_args_destroy(r->resolved_result); + if (r->resolved_result_ != nullptr) { + grpc_channel_args_destroy(r->resolved_result_); } - r->resolved_result = result; - r->resolved_version++; - dns_maybe_finish_next_locked(r); + r->resolved_result_ = result; + ++r->resolved_version_; + r->MaybeFinishNextLocked(); GRPC_ERROR_UNREF(error); - - GRPC_RESOLVER_UNREF(&r->base, "dns-resolving"); + r->Unref(DEBUG_LOCATION, "dns-resolving"); } -static void maybe_start_resolving_locked(dns_resolver* r) { - if (r->last_resolution_timestamp >= 0) { +void NativeDnsResolver::MaybeStartResolvingLocked() { + if (last_resolution_timestamp_ >= 0) { const grpc_millis earliest_next_resolution = - r->last_resolution_timestamp + r->min_time_between_resolutions; + last_resolution_timestamp_ + min_time_between_resolutions_; const grpc_millis ms_until_next_resolution = earliest_next_resolution - grpc_core::ExecCtx::Get()->Now(); if (ms_until_next_resolution > 0) { const grpc_millis last_resolution_ago = - grpc_core::ExecCtx::Get()->Now() - r->last_resolution_timestamp; + grpc_core::ExecCtx::Get()->Now() - last_resolution_timestamp_; gpr_log(GPR_DEBUG, "In cooldown from last resolution (from %" PRIdPTR " ms ago). Will resolve again in %" PRIdPTR " ms", last_resolution_ago, ms_until_next_resolution); - if (!r->have_next_resolution_timer) { - r->have_next_resolution_timer = true; - GRPC_RESOLVER_REF(&r->base, "next_resolution_timer_cooldown"); - grpc_timer_init(&r->next_resolution_timer, ms_until_next_resolution, - &r->next_resolution_closure); + if (!have_next_resolution_timer_) { + have_next_resolution_timer_ = true; + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = + Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown"); + self.release(); + grpc_timer_init(&next_resolution_timer_, ms_until_next_resolution, + &on_next_resolution_); } // TODO(dgq): remove the following two lines once Pick First stops // discarding subchannels after selecting. - ++r->resolved_version; - dns_maybe_finish_next_locked(r); + ++resolved_version_; + MaybeFinishNextLocked(); return; } } - dns_start_resolving_locked(r); + StartResolvingLocked(); } -static void dns_start_resolving_locked(dns_resolver* r) { - GRPC_RESOLVER_REF(&r->base, "dns-resolving"); - GPR_ASSERT(!r->resolving); - r->resolving = true; - r->addresses = nullptr; - grpc_resolve_address( - r->name_to_resolve, r->default_port, r->interested_parties, - GRPC_CLOSURE_CREATE(dns_on_resolved_locked, r, - grpc_combiner_scheduler(r->base.combiner)), - &r->addresses); - r->last_resolution_timestamp = grpc_core::ExecCtx::Get()->Now(); +void NativeDnsResolver::StartResolvingLocked() { + // TODO(roth): We currently deal with this ref manually. Once the + // new closure API is done, find a way to track this ref with the timer + // callback as part of the type system. + RefCountedPtr self = Ref(DEBUG_LOCATION, "dns-resolving"); + self.release(); + GPR_ASSERT(!resolving_); + resolving_ = true; + addresses_ = nullptr; + grpc_resolve_address(name_to_resolve_, kDefaultPort, interested_parties_, + &on_resolved_, &addresses_); + last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now(); } -static void dns_maybe_finish_next_locked(dns_resolver* r) { - if (r->next_completion != nullptr && - r->resolved_version != r->published_version) { - *r->target_result = r->resolved_result == nullptr - ? nullptr - : grpc_channel_args_copy(r->resolved_result); - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE); - r->next_completion = nullptr; - r->published_version = r->resolved_version; +void NativeDnsResolver::MaybeFinishNextLocked() { + if (next_completion_ != nullptr && resolved_version_ != published_version_) { + *target_result_ = resolved_result_ == nullptr + ? nullptr + : grpc_channel_args_copy(resolved_result_); + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE); + next_completion_ = nullptr; + published_version_ = resolved_version_; } } -static void dns_destroy(grpc_resolver* gr) { - dns_resolver* r = (dns_resolver*)gr; - if (r->resolved_result != nullptr) { - grpc_channel_args_destroy(r->resolved_result); - } - grpc_pollset_set_destroy(r->interested_parties); - gpr_free(r->name_to_resolve); - gpr_free(r->default_port); - grpc_channel_args_destroy(r->channel_args); - gpr_free(r); -} +// +// Factory +// -static grpc_resolver* dns_create(grpc_resolver_args* args, - const char* default_port) { - if (0 != strcmp(args->uri->authority, "")) { - gpr_log(GPR_ERROR, "authority based dns uri's not supported"); - return nullptr; - } - // Get name from args. - char* path = args->uri->path; - if (path[0] == '/') ++path; - // Create resolver. - dns_resolver* r = (dns_resolver*)gpr_zalloc(sizeof(dns_resolver)); - grpc_resolver_init(&r->base, &dns_resolver_vtable, args->combiner); - r->name_to_resolve = gpr_strdup(path); - r->default_port = gpr_strdup(default_port); - r->channel_args = grpc_channel_args_copy(args->args); - r->interested_parties = grpc_pollset_set_create(); - if (args->pollset_set != nullptr) { - grpc_pollset_set_add_pollset_set(r->interested_parties, args->pollset_set); +class NativeDnsResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + if (0 != strcmp(args.uri->authority, "")) { + gpr_log(GPR_ERROR, "authority based dns uri's not supported"); + return OrphanablePtr(nullptr); + } + return OrphanablePtr(New(args)); } - grpc_core::BackOff::Options backoff_options; - backoff_options - .set_initial_backoff(GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000) - .set_multiplier(GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER) - .set_jitter(GRPC_DNS_RECONNECT_JITTER) - .set_max_backoff(GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); - r->backoff.Init(grpc_core::BackOff(backoff_options)); - const grpc_arg* period_arg = grpc_channel_args_find( - args->args, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); - r->min_time_between_resolutions = - grpc_channel_arg_get_integer(period_arg, {1000, 0, INT_MAX}); - r->last_resolution_timestamp = -1; - GRPC_CLOSURE_INIT(&r->next_resolution_closure, - dns_on_next_resolution_timer_locked, r, - grpc_combiner_scheduler(r->base.combiner)); - return &r->base; -} -/* - * FACTORY - */ + const char* scheme() const override { return "dns"; } +}; -static void dns_factory_ref(grpc_resolver_factory* factory) {} +} // namespace -static void dns_factory_unref(grpc_resolver_factory* factory) {} +} // namespace grpc_core -static grpc_resolver* dns_factory_create_resolver( - grpc_resolver_factory* factory, grpc_resolver_args* args) { - return dns_create(args, "https"); -} - -static char* dns_factory_get_default_host_name(grpc_resolver_factory* factory, - grpc_uri* uri) { - const char* path = uri->path; - if (path[0] == '/') ++path; - return gpr_strdup(path); -} - -static const grpc_resolver_factory_vtable dns_factory_vtable = { - dns_factory_ref, dns_factory_unref, dns_factory_create_resolver, - dns_factory_get_default_host_name, "dns"}; -static grpc_resolver_factory dns_resolver_factory = {&dns_factory_vtable}; - -static grpc_resolver_factory* dns_resolver_factory_create() { - return &dns_resolver_factory; -} - -void grpc_resolver_dns_native_init(void) { - char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver != nullptr && gpr_stricmp(resolver, "native") == 0) { +void grpc_resolver_dns_native_init() { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { gpr_log(GPR_DEBUG, "Using native dns resolver"); - grpc_register_resolver_type(dns_resolver_factory_create()); + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); } else { - grpc_resolver_factory* existing_factory = - grpc_resolver_factory_lookup("dns"); + grpc_core::ResolverRegistry::Builder::InitRegistry(); + grpc_core::ResolverFactory* existing_factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); if (existing_factory == nullptr) { gpr_log(GPR_DEBUG, "Using native dns resolver"); - grpc_register_resolver_type(dns_resolver_factory_create()); - } else { - grpc_resolver_factory_unref(existing_factory); + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); } } - gpr_free(resolver); + gpr_free(resolver_env); } -void grpc_resolver_dns_native_shutdown(void) {} +void grpc_resolver_dns_native_shutdown() {} 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 f457917775..b01e608c3f 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 @@ -42,190 +42,177 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" -// -// fake_resolver -// +namespace grpc_core { -typedef struct { - // Base class -- must be first - grpc_resolver base; +// This cannot be in an anonymous namespace, because it is a friend of +// FakeResolverResponseGenerator. +class FakeResolver : public Resolver { + public: + explicit FakeResolver(const ResolverArgs& args); - // Passed-in parameters - grpc_channel_args* channel_args; + void NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) override; - // If not NULL, the next set of resolution results to be returned to - // grpc_resolver_next_locked()'s closure. - grpc_channel_args* next_results; + void RequestReresolutionLocked() override; - // Results to use for the pretended re-resolution in - // fake_resolver_channel_saw_error_locked(). - grpc_channel_args* results_upon_error; + private: + friend class FakeResolverResponseGenerator; + + virtual ~FakeResolver(); + void MaybeFinishNextLocked(); + + void ShutdownLocked() override; + + // passed-in parameters + grpc_channel_args* channel_args_ = nullptr; + // If not NULL, the next set of resolution results to be returned to + // NextLocked()'s closure. + grpc_channel_args* next_results_ = nullptr; + // Results to use for the pretended re-resolution in + // RequestReresolutionLocked(). + grpc_channel_args* reresolution_results_ = nullptr; // TODO(juanlishen): This can go away once pick_first is changed to not throw // away its subchannels, since that will eliminate its dependence on // channel_saw_error_locked() causing an immediate resolver return. // A copy of the most-recently used resolution results. - grpc_channel_args* last_used_results; - - // Pending next completion, or NULL - grpc_closure* next_completion; - - // Target result address for next completion - grpc_channel_args** target_result; -} fake_resolver; - -static void fake_resolver_destroy(grpc_resolver* gr) { - fake_resolver* r = (fake_resolver*)gr; - grpc_channel_args_destroy(r->next_results); - grpc_channel_args_destroy(r->results_upon_error); - grpc_channel_args_destroy(r->last_used_results); - grpc_channel_args_destroy(r->channel_args); - gpr_free(r); + grpc_channel_args* last_used_results_ = nullptr; + // pending next completion, or NULL + grpc_closure* next_completion_ = nullptr; + // target result address for next completion + grpc_channel_args** target_result_ = nullptr; +}; + +FakeResolver::FakeResolver(const ResolverArgs& args) : Resolver(args.combiner) { + channel_args_ = grpc_channel_args_copy(args.args); + FakeResolverResponseGenerator* response_generator = + FakeResolverResponseGenerator::GetFromArgs(args.args); + if (response_generator != nullptr) response_generator->resolver_ = this; } -static void fake_resolver_shutdown_locked(grpc_resolver* resolver) { - fake_resolver* r = (fake_resolver*)resolver; - if (r->next_completion != nullptr) { - *r->target_result = nullptr; - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Resolver Shutdown")); - r->next_completion = nullptr; - } +FakeResolver::~FakeResolver() { + grpc_channel_args_destroy(next_results_); + grpc_channel_args_destroy(reresolution_results_); + grpc_channel_args_destroy(last_used_results_); + grpc_channel_args_destroy(channel_args_); } -static void fake_resolver_maybe_finish_next_locked(fake_resolver* r) { - if (r->next_completion != nullptr && r->next_results != nullptr) { - *r->target_result = - grpc_channel_args_union(r->next_results, r->channel_args); - grpc_channel_args_destroy(r->next_results); - r->next_results = nullptr; - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE); - r->next_completion = nullptr; - } +void FakeResolver::NextLocked(grpc_channel_args** target_result, + grpc_closure* on_complete) { + GPR_ASSERT(next_completion_ == nullptr); + next_completion_ = on_complete; + target_result_ = target_result; + MaybeFinishNextLocked(); } -static void fake_resolver_channel_saw_error_locked(grpc_resolver* resolver) { - fake_resolver* r = (fake_resolver*)resolver; +void FakeResolver::RequestReresolutionLocked() { // A resolution must have been returned before an error is seen. - GPR_ASSERT(r->last_used_results != nullptr); - grpc_channel_args_destroy(r->next_results); - if (r->results_upon_error != nullptr) { - r->next_results = grpc_channel_args_copy(r->results_upon_error); + GPR_ASSERT(last_used_results_ != nullptr); + grpc_channel_args_destroy(next_results_); + if (reresolution_results_ != nullptr) { + next_results_ = grpc_channel_args_copy(reresolution_results_); } else { - // If results_upon_error is unavailable, re-resolve with the most-recently + // If reresolution_results is unavailable, re-resolve with the most-recently // used results to avoid a no-op re-resolution. - r->next_results = grpc_channel_args_copy(r->last_used_results); + next_results_ = grpc_channel_args_copy(last_used_results_); } - fake_resolver_maybe_finish_next_locked(r); -} - -static void fake_resolver_next_locked(grpc_resolver* resolver, - grpc_channel_args** target_result, - grpc_closure* on_complete) { - fake_resolver* r = (fake_resolver*)resolver; - GPR_ASSERT(!r->next_completion); - r->next_completion = on_complete; - r->target_result = target_result; - fake_resolver_maybe_finish_next_locked(r); -} - -static const grpc_resolver_vtable fake_resolver_vtable = { - fake_resolver_destroy, fake_resolver_shutdown_locked, - fake_resolver_channel_saw_error_locked, fake_resolver_next_locked}; - -struct grpc_fake_resolver_response_generator { - fake_resolver* resolver; // Set by the fake_resolver constructor to itself. - gpr_refcount refcount; -}; - -grpc_fake_resolver_response_generator* -grpc_fake_resolver_response_generator_create() { - grpc_fake_resolver_response_generator* generator = - (grpc_fake_resolver_response_generator*)gpr_zalloc(sizeof(*generator)); - gpr_ref_init(&generator->refcount, 1); - return generator; + MaybeFinishNextLocked(); } -grpc_fake_resolver_response_generator* -grpc_fake_resolver_response_generator_ref( - grpc_fake_resolver_response_generator* generator) { - gpr_ref(&generator->refcount); - return generator; +void FakeResolver::MaybeFinishNextLocked() { + if (next_completion_ != nullptr && next_results_ != nullptr) { + *target_result_ = grpc_channel_args_union(next_results_, channel_args_); + grpc_channel_args_destroy(next_results_); + next_results_ = nullptr; + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE); + next_completion_ = nullptr; + } } -void grpc_fake_resolver_response_generator_unref( - grpc_fake_resolver_response_generator* generator) { - if (gpr_unref(&generator->refcount)) { - gpr_free(generator); +void FakeResolver::ShutdownLocked() { + if (next_completion_ != nullptr) { + *target_result_ = nullptr; + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Resolver Shutdown")); + next_completion_ = nullptr; } } -typedef struct set_response_closure_arg { +// +// FakeResolverResponseGenerator +// + +struct SetResponseClosureArg { grpc_closure set_response_closure; - grpc_fake_resolver_response_generator* generator; + FakeResolverResponseGenerator* generator; grpc_channel_args* response; - bool upon_error; -} set_response_closure_arg; - -static void set_response_closure_locked(void* arg, grpc_error* error) { - set_response_closure_arg* closure_arg = (set_response_closure_arg*)arg; - grpc_fake_resolver_response_generator* generator = closure_arg->generator; - fake_resolver* r = generator->resolver; - if (!closure_arg->upon_error) { - grpc_channel_args_destroy(r->next_results); - r->next_results = closure_arg->response; - grpc_channel_args_destroy(r->last_used_results); - r->last_used_results = grpc_channel_args_copy(closure_arg->response); - fake_resolver_maybe_finish_next_locked(r); - } else { - grpc_channel_args_destroy(r->results_upon_error); - r->results_upon_error = closure_arg->response; - } - gpr_free(closure_arg); +}; + +void FakeResolverResponseGenerator::SetResponseLocked(void* arg, + grpc_error* error) { + SetResponseClosureArg* closure_arg = static_cast(arg); + FakeResolver* resolver = closure_arg->generator->resolver_; + grpc_channel_args_destroy(resolver->next_results_); + resolver->next_results_ = closure_arg->response; + grpc_channel_args_destroy(resolver->last_used_results_); + resolver->last_used_results_ = grpc_channel_args_copy(closure_arg->response); + resolver->MaybeFinishNextLocked(); + Delete(closure_arg); } -void grpc_fake_resolver_response_generator_set_response( - grpc_fake_resolver_response_generator* generator, - grpc_channel_args* response) { - GPR_ASSERT(generator->resolver != nullptr); +void FakeResolverResponseGenerator::SetResponse(grpc_channel_args* response) { GPR_ASSERT(response != nullptr); - set_response_closure_arg* closure_arg = - (set_response_closure_arg*)gpr_zalloc(sizeof(*closure_arg)); - closure_arg->generator = generator; + GPR_ASSERT(resolver_ != nullptr); + SetResponseClosureArg* closure_arg = New(); + closure_arg->generator = this; closure_arg->response = grpc_channel_args_copy(response); - closure_arg->upon_error = false; - GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, - set_response_closure_locked, closure_arg, - grpc_combiner_scheduler( - generator->resolver->base.combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetResponseLocked, + closure_arg, + grpc_combiner_scheduler(resolver_->combiner())), + GRPC_ERROR_NONE); } -void grpc_fake_resolver_response_generator_set_response_upon_error( - grpc_fake_resolver_response_generator* generator, +void FakeResolverResponseGenerator::SetReresolutionResponseLocked( + void* arg, grpc_error* error) { + SetResponseClosureArg* closure_arg = static_cast(arg); + FakeResolver* resolver = closure_arg->generator->resolver_; + grpc_channel_args_destroy(resolver->reresolution_results_); + resolver->reresolution_results_ = closure_arg->response; + Delete(closure_arg); +} + +void FakeResolverResponseGenerator::SetReresolutionResponse( grpc_channel_args* response) { - GPR_ASSERT(generator->resolver != nullptr); - set_response_closure_arg* closure_arg = - (set_response_closure_arg*)gpr_zalloc(sizeof(*closure_arg)); - closure_arg->generator = generator; + GPR_ASSERT(resolver_ != nullptr); + SetResponseClosureArg* closure_arg = New(); + closure_arg->generator = this; closure_arg->response = response != nullptr ? grpc_channel_args_copy(response) : nullptr; - closure_arg->upon_error = true; - GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, - set_response_closure_locked, closure_arg, - grpc_combiner_scheduler( - generator->resolver->base.combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, + SetReresolutionResponseLocked, closure_arg, + grpc_combiner_scheduler(resolver_->combiner())), + GRPC_ERROR_NONE); } +namespace { + static void* response_generator_arg_copy(void* p) { - return grpc_fake_resolver_response_generator_ref( - (grpc_fake_resolver_response_generator*)p); + FakeResolverResponseGenerator* generator = + static_cast(p); + // TODO(roth): We currently deal with this ref manually. Once the + // new channel args code is converted to C++, find a way to track this ref + // in a cleaner way. + RefCountedPtr copy = generator->Ref(); + copy.release(); + return p; } static void response_generator_arg_destroy(void* p) { - grpc_fake_resolver_response_generator_unref( - (grpc_fake_resolver_response_generator*)p); + FakeResolverResponseGenerator* generator = + static_cast(p); + generator->Unref(); } static int response_generator_cmp(void* a, void* b) { return GPR_ICMP(a, b); } @@ -234,8 +221,10 @@ static const grpc_arg_pointer_vtable response_generator_arg_vtable = { response_generator_arg_copy, response_generator_arg_destroy, response_generator_cmp}; -grpc_arg grpc_fake_resolver_response_generator_arg( - grpc_fake_resolver_response_generator* generator) { +} // namespace + +grpc_arg FakeResolverResponseGenerator::MakeChannelArg( + FakeResolverResponseGenerator* generator) { grpc_arg arg; arg.type = GRPC_ARG_POINTER; arg.key = (char*)GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR; @@ -244,49 +233,38 @@ grpc_arg grpc_fake_resolver_response_generator_arg( return arg; } -grpc_fake_resolver_response_generator* -grpc_fake_resolver_get_response_generator(const grpc_channel_args* args) { +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 (grpc_fake_resolver_response_generator*)arg->value.pointer.p; + return static_cast(arg->value.pointer.p); } // -// fake_resolver_factory +// Factory // -static void fake_resolver_factory_ref(grpc_resolver_factory* factory) {} - -static void fake_resolver_factory_unref(grpc_resolver_factory* factory) {} +namespace { -static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory, - grpc_resolver_args* args) { - fake_resolver* r = (fake_resolver*)gpr_zalloc(sizeof(*r)); - r->channel_args = grpc_channel_args_copy(args->args); - grpc_resolver_init(&r->base, &fake_resolver_vtable, args->combiner); - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_get_response_generator(args->args); - if (response_generator != nullptr) response_generator->resolver = r; - return &r->base; -} +class FakeResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + return OrphanablePtr(New(args)); + } -static char* fake_resolver_get_default_authority(grpc_resolver_factory* factory, - grpc_uri* uri) { - const char* path = uri->path; - if (path[0] == '/') ++path; - return gpr_strdup(path); -} + const char* scheme() const override { return "fake"; } +}; -static const grpc_resolver_factory_vtable fake_resolver_factory_vtable = { - fake_resolver_factory_ref, fake_resolver_factory_unref, - fake_resolver_create, fake_resolver_get_default_authority, "fake"}; +} // namespace -static grpc_resolver_factory fake_resolver_factory = { - &fake_resolver_factory_vtable}; +} // namespace grpc_core -void grpc_resolver_fake_init(void) { - grpc_register_resolver_type(&fake_resolver_factory); +void grpc_resolver_fake_init() { + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); } -void grpc_resolver_fake_shutdown(void) {} +void grpc_resolver_fake_shutdown() {} diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h index 94f9a8e6ca..d42811d913 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h @@ -20,50 +20,57 @@ #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/ref_counted.h" #define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR \ "grpc.fake_resolver.response_generator" -void grpc_resolver_fake_init(); +namespace grpc_core { -// Instances of \a grpc_fake_resolver_response_generator are passed to the -// fake resolver in a channel argument (see \a -// grpc_fake_resolver_response_generator_arg) in order to inject and trigger -// custom resolutions. See also \a -// grpc_fake_resolver_response_generator_set_response. -typedef struct grpc_fake_resolver_response_generator - grpc_fake_resolver_response_generator; -grpc_fake_resolver_response_generator* -grpc_fake_resolver_response_generator_create(); +class FakeResolver; -// Set next response of the fake resolver associated with the \a -// response_generator instance and trigger a new resolution. -void grpc_fake_resolver_response_generator_set_response( - grpc_fake_resolver_response_generator* generator, - grpc_channel_args* response); +/// A mechanism for generating responses for the fake resolver. +/// An instance of this class is passed to the fake resolver via a channel +/// argument (see \a MakeChannelArg()) and used to inject and trigger custom +/// resolutions. +// TODO(roth): I would ideally like this to be InternallyRefCounted +// instead of RefCounted, but external refs are currently needed to +// encode this in channel args. Once channel_args are converted to C++, +// see if we can find a way to fix this. +class FakeResolverResponseGenerator + : public RefCounted { + public: + FakeResolverResponseGenerator() {} -// Set results_upon_error of the fake resolver associated with the \a -// response_generator instance. When fake_resolver_channel_saw_error_locked() is -// called, results_upon_error will be returned as long as it's non-NULL, -// otherwise the last value set by -// grpc_fake_resolver_response_generator_set_response() will be returned. -void grpc_fake_resolver_response_generator_set_response_upon_error( - grpc_fake_resolver_response_generator* generator, - grpc_channel_args* response); + // Instructs the fake resolver associated with the response generator + // instance to trigger a new resolution with the specified response. + void SetResponse(grpc_channel_args* next_response); -// Return a \a grpc_arg for a \a grpc_fake_resolver_response_generator instance. -grpc_arg grpc_fake_resolver_response_generator_arg( - grpc_fake_resolver_response_generator* generator); -// Return the \a grpc_fake_resolver_response_generator instance in \a args or -// NULL. -grpc_fake_resolver_response_generator* -grpc_fake_resolver_get_response_generator(const grpc_channel_args* args); + // Sets the re-resolution response, which is returned by the fake resolver + // when re-resolution is requested (via \a RequestReresolutionLocked()). + // The new re-resolution response replaces any previous re-resolution + // response that may have been set by a previous call. + // If the re-resolution response is set to NULL, then the fake + // resolver will return the last value set via \a SetResponse(). + void SetReresolutionResponse(grpc_channel_args* response); -grpc_fake_resolver_response_generator* -grpc_fake_resolver_response_generator_ref( - grpc_fake_resolver_response_generator* generator); -void grpc_fake_resolver_response_generator_unref( - grpc_fake_resolver_response_generator* generator); + // Returns a channel arg containing \a generator. + static grpc_arg MakeChannelArg(FakeResolverResponseGenerator* generator); + + // Returns the response generator in \a args, or null if not found. + static FakeResolverResponseGenerator* GetFromArgs( + const grpc_channel_args* args); + + private: + friend class FakeResolver; + + static void SetResponseLocked(void* arg, grpc_error* error); + static void SetReresolutionResponseLocked(void* arg, grpc_error* error); + + FakeResolver* resolver_ = nullptr; // Do not own. +}; + +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FAKE_FAKE_RESOLVER_H \ */ diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 784935eb20..966b9fd3f2 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -37,115 +37,99 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" -typedef struct { - /** base class: must be first */ - grpc_resolver base; - /** the addresses that we've 'resolved' */ - grpc_lb_addresses* addresses; - /** channel args */ - grpc_channel_args* channel_args; - /** have we published? */ - bool published; - /** pending next completion, or NULL */ - grpc_closure* next_completion; - /** target result address for next completion */ - grpc_channel_args** target_result; -} sockaddr_resolver; - -static void sockaddr_destroy(grpc_resolver* r); - -static void sockaddr_maybe_finish_next_locked(sockaddr_resolver* r); - -static void sockaddr_shutdown_locked(grpc_resolver* r); -static void sockaddr_channel_saw_error_locked(grpc_resolver* r); -static void sockaddr_next_locked(grpc_resolver* r, - grpc_channel_args** target_result, - grpc_closure* on_complete); - -static const grpc_resolver_vtable sockaddr_resolver_vtable = { - sockaddr_destroy, sockaddr_shutdown_locked, - sockaddr_channel_saw_error_locked, sockaddr_next_locked}; - -static void sockaddr_shutdown_locked(grpc_resolver* resolver) { - sockaddr_resolver* r = (sockaddr_resolver*)resolver; - if (r->next_completion != nullptr) { - *r->target_result = nullptr; - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Resolver Shutdown")); - r->next_completion = nullptr; - } -} +namespace grpc_core { -static void sockaddr_channel_saw_error_locked(grpc_resolver* resolver) { - sockaddr_resolver* r = (sockaddr_resolver*)resolver; - r->published = false; - sockaddr_maybe_finish_next_locked(r); -} +namespace { -static void sockaddr_next_locked(grpc_resolver* resolver, - grpc_channel_args** target_result, - grpc_closure* on_complete) { - sockaddr_resolver* r = (sockaddr_resolver*)resolver; - GPR_ASSERT(!r->next_completion); - r->next_completion = on_complete; - r->target_result = target_result; - sockaddr_maybe_finish_next_locked(r); -} +class SockaddrResolver : public Resolver { + public: + /// Takes ownership of \a addresses. + SockaddrResolver(const ResolverArgs& args, grpc_lb_addresses* addresses); -static void sockaddr_maybe_finish_next_locked(sockaddr_resolver* r) { - if (r->next_completion != nullptr && !r->published) { - r->published = true; - grpc_arg arg = grpc_lb_addresses_create_channel_arg(r->addresses); - *r->target_result = - grpc_channel_args_copy_and_add(r->channel_args, &arg, 1); - GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE); - r->next_completion = nullptr; - } -} + void NextLocked(grpc_channel_args** result, + grpc_closure* on_complete) override; + + void RequestReresolutionLocked() override; -static void sockaddr_destroy(grpc_resolver* gr) { - sockaddr_resolver* r = (sockaddr_resolver*)gr; - grpc_lb_addresses_destroy(r->addresses); - grpc_channel_args_destroy(r->channel_args); - gpr_free(r); + void ShutdownLocked() override; + + private: + virtual ~SockaddrResolver(); + + void MaybeFinishNextLocked(); + + /// the addresses that we've "resolved" + grpc_lb_addresses* addresses_ = nullptr; + /// channel args + grpc_channel_args* channel_args_ = nullptr; + /// have we published? + bool published_ = false; + /// pending next completion, or NULL + grpc_closure* next_completion_ = nullptr; + /// target result address for next completion + grpc_channel_args** target_result_ = nullptr; +}; + +SockaddrResolver::SockaddrResolver(const ResolverArgs& args, + grpc_lb_addresses* addresses) + : Resolver(args.combiner), + addresses_(addresses), + channel_args_(grpc_channel_args_copy(args.args)) {} + +SockaddrResolver::~SockaddrResolver() { + grpc_lb_addresses_destroy(addresses_); + grpc_channel_args_destroy(channel_args_); } -static char* ip_get_default_authority(grpc_uri* uri) { - const char* path = uri->path; - if (path[0] == '/') ++path; - return gpr_strdup(path); +void SockaddrResolver::NextLocked(grpc_channel_args** target_result, + grpc_closure* on_complete) { + GPR_ASSERT(!next_completion_); + next_completion_ = on_complete; + target_result_ = target_result; + MaybeFinishNextLocked(); } -static char* ipv4_get_default_authority(grpc_resolver_factory* factory, - grpc_uri* uri) { - return ip_get_default_authority(uri); +void SockaddrResolver::RequestReresolutionLocked() { + published_ = false; + MaybeFinishNextLocked(); } -static char* ipv6_get_default_authority(grpc_resolver_factory* factory, - grpc_uri* uri) { - return ip_get_default_authority(uri); +void SockaddrResolver::ShutdownLocked() { + if (next_completion_ != nullptr) { + *target_result_ = nullptr; + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Resolver Shutdown")); + next_completion_ = nullptr; + } } -#ifdef GRPC_HAVE_UNIX_SOCKET -char* unix_get_default_authority(grpc_resolver_factory* factory, - grpc_uri* uri) { - return gpr_strdup("localhost"); +void SockaddrResolver::MaybeFinishNextLocked() { + if (next_completion_ != nullptr && !published_) { + published_ = true; + grpc_arg arg = grpc_lb_addresses_create_channel_arg(addresses_); + *target_result_ = grpc_channel_args_copy_and_add(channel_args_, &arg, 1); + GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE); + next_completion_ = nullptr; + } } -#endif -static void do_nothing(void* ignored) {} +// +// Factory +// -static grpc_resolver* sockaddr_create(grpc_resolver_args* args, - bool parse(const grpc_uri* uri, - grpc_resolved_address* dst)) { - if (0 != strcmp(args->uri->authority, "")) { - gpr_log(GPR_ERROR, "authority based uri's not supported by the %s scheme", - args->uri->scheme); - return nullptr; +void DoNothing(void* ignored) {} + +OrphanablePtr CreateSockaddrResolver( + const ResolverArgs& args, + bool parse(const grpc_uri* uri, grpc_resolved_address* dst)) { + if (0 != strcmp(args.uri->authority, "")) { + gpr_log(GPR_ERROR, "authority-based URIs not supported by the %s scheme", + args.uri->scheme); + return OrphanablePtr(nullptr); } - /* Construct addresses. */ + // Construct addresses. grpc_slice path_slice = - grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); + grpc_slice_new(args.uri->path, strlen(args.uri->path), DoNothing); grpc_slice_buffer path_parts; grpc_slice_buffer_init(&path_parts); grpc_slice_split(path_slice, ",", &path_parts); @@ -153,7 +137,7 @@ static grpc_resolver* sockaddr_create(grpc_resolver_args* args, path_parts.count, nullptr /* user_data_vtable */); bool errors_found = false; for (size_t i = 0; i < addresses->num_addresses; i++) { - grpc_uri ith_uri = *args->uri; + grpc_uri ith_uri = *args.uri; char* part_str = grpc_slice_to_c_string(path_parts.slices[i]); ith_uri.path = part_str; if (!parse(&ith_uri, &addresses->addresses[i].address)) { @@ -166,48 +150,64 @@ static grpc_resolver* sockaddr_create(grpc_resolver_args* args, grpc_slice_unref_internal(path_slice); if (errors_found) { grpc_lb_addresses_destroy(addresses); - return nullptr; + return OrphanablePtr(nullptr); } - /* Instantiate resolver. */ - sockaddr_resolver* r = - (sockaddr_resolver*)gpr_zalloc(sizeof(sockaddr_resolver)); - r->addresses = addresses; - r->channel_args = grpc_channel_args_copy(args->args); - grpc_resolver_init(&r->base, &sockaddr_resolver_vtable, args->combiner); - return &r->base; + // Instantiate resolver. + return OrphanablePtr(New(args, addresses)); } -/* - * FACTORY - */ +class IPv4ResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + return CreateSockaddrResolver(args, grpc_parse_ipv4); + } -static void sockaddr_factory_ref(grpc_resolver_factory* factory) {} + const char* scheme() const override { return "ipv4"; } +}; -static void sockaddr_factory_unref(grpc_resolver_factory* factory) {} +class IPv6ResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + return CreateSockaddrResolver(args, grpc_parse_ipv6); + } -#define DECL_FACTORY(name) \ - static grpc_resolver* name##_factory_create_resolver( \ - grpc_resolver_factory* factory, grpc_resolver_args* args) { \ - return sockaddr_create(args, grpc_parse_##name); \ - } \ - static const grpc_resolver_factory_vtable name##_factory_vtable = { \ - sockaddr_factory_ref, sockaddr_factory_unref, \ - name##_factory_create_resolver, name##_get_default_authority, #name}; \ - static grpc_resolver_factory name##_resolver_factory = { \ - &name##_factory_vtable} + const char* scheme() const override { return "ipv6"; } +}; #ifdef GRPC_HAVE_UNIX_SOCKET -DECL_FACTORY(unix); -#endif -DECL_FACTORY(ipv4); -DECL_FACTORY(ipv6); +class UnixResolverFactory : public ResolverFactory { + public: + OrphanablePtr CreateResolver( + const ResolverArgs& args) const override { + return CreateSockaddrResolver(args, grpc_parse_unix); + } + + UniquePtr GetDefaultAuthority(grpc_uri* uri) const override { + return UniquePtr(gpr_strdup("localhost")); + } + + const char* scheme() const override { return "unix"; } +}; +#endif // GRPC_HAVE_UNIX_SOCKET + +} // namespace + +} // namespace grpc_core -void grpc_resolver_sockaddr_init(void) { - grpc_register_resolver_type(&ipv4_resolver_factory); - grpc_register_resolver_type(&ipv6_resolver_factory); +void grpc_resolver_sockaddr_init() { + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); #ifdef GRPC_HAVE_UNIX_SOCKET - grpc_register_resolver_type(&unix_resolver_factory); + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); #endif } -void grpc_resolver_sockaddr_shutdown(void) {} +void grpc_resolver_sockaddr_shutdown() {} diff --git a/src/core/ext/filters/client_channel/resolver_factory.cc b/src/core/ext/filters/client_channel/resolver_factory.cc deleted file mode 100644 index 9b3ec2f1c4..0000000000 --- a/src/core/ext/filters/client_channel/resolver_factory.cc +++ /dev/null @@ -1,40 +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. - * - */ - -#include "src/core/ext/filters/client_channel/resolver_factory.h" - -void grpc_resolver_factory_ref(grpc_resolver_factory* factory) { - factory->vtable->ref(factory); -} - -void grpc_resolver_factory_unref(grpc_resolver_factory* factory) { - factory->vtable->unref(factory); -} - -/** Create a resolver instance for a name */ -grpc_resolver* grpc_resolver_factory_create_resolver( - grpc_resolver_factory* factory, grpc_resolver_args* args) { - if (factory == nullptr) return nullptr; - return factory->vtable->create_resolver(factory, args); -} - -char* grpc_resolver_factory_get_default_authority( - grpc_resolver_factory* factory, grpc_uri* uri) { - if (factory == nullptr) return nullptr; - return factory->vtable->get_default_authority(factory, uri); -} diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 170ecc0b48..f9b9501236 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -19,50 +19,51 @@ #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H -#include "src/core/ext/filters/client_channel/client_channel_factory.h" +#include + #include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/ext/filters/client_channel/uri_parser.h" +#include "src/core/lib/gprpp/abstract.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/pollset_set.h" -typedef struct grpc_resolver_factory grpc_resolver_factory; -typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable; +namespace grpc_core { -struct grpc_resolver_factory { - const grpc_resolver_factory_vtable* vtable; +struct ResolverArgs { + /// The parsed URI to resolve. + grpc_uri* uri = nullptr; + /// Channel args to be included in resolver results. + const grpc_channel_args* args = nullptr; + /// Used to drive I/O in the name resolution process. + grpc_pollset_set* pollset_set = nullptr; + /// The combiner under which all resolver calls will be run. + grpc_combiner* combiner = nullptr; }; -typedef struct grpc_resolver_args { - grpc_uri* uri; - const grpc_channel_args* args; - grpc_pollset_set* pollset_set; - grpc_combiner* combiner; -} grpc_resolver_args; +class ResolverFactory { + public: + /// Returns a new resolver instance. + virtual OrphanablePtr CreateResolver(const ResolverArgs& args) const + GRPC_ABSTRACT; -struct grpc_resolver_factory_vtable { - void (*ref)(grpc_resolver_factory* factory); - void (*unref)(grpc_resolver_factory* factory); + /// Returns a string representing the default authority to use for this + /// scheme. + virtual UniquePtr GetDefaultAuthority(grpc_uri* uri) const { + const char* path = uri->path; + if (path[0] == '/') ++path; + return UniquePtr(gpr_strdup(path)); + } - /** Implementation of grpc_resolver_factory_create_resolver */ - grpc_resolver* (*create_resolver)(grpc_resolver_factory* factory, - grpc_resolver_args* args); + /// Returns the URI scheme that this factory implements. + /// Caller does NOT take ownership of result. + virtual const char* scheme() const GRPC_ABSTRACT; - /** Implementation of grpc_resolver_factory_get_default_authority */ - char* (*get_default_authority)(grpc_resolver_factory* factory, grpc_uri* uri); + virtual ~ResolverFactory() {} - /** URI scheme that this factory implements */ - const char* scheme; + GRPC_ABSTRACT_BASE_CLASS }; -void grpc_resolver_factory_ref(grpc_resolver_factory* resolver); -void grpc_resolver_factory_unref(grpc_resolver_factory* resolver); - -/** Create a resolver instance for a name */ -grpc_resolver* grpc_resolver_factory_create_resolver( - grpc_resolver_factory* factory, grpc_resolver_args* args); - -/** Return a (freshly allocated with gpr_malloc) string representing - the default authority to use for this scheme. */ -char* grpc_resolver_factory_get_default_authority( - grpc_resolver_factory* factory, grpc_uri* uri); +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc index 3f8451de6b..036e81d0ae 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.cc +++ b/src/core/ext/filters/client_channel/resolver_registry.cc @@ -24,133 +24,153 @@ #include #include -#define MAX_RESOLVERS 10 -#define DEFAULT_RESOLVER_PREFIX_MAX_LENGTH 32 +namespace grpc_core { -static grpc_resolver_factory* g_all_of_the_resolvers[MAX_RESOLVERS]; -static int g_number_of_resolvers = 0; +namespace { -static char g_default_resolver_prefix[DEFAULT_RESOLVER_PREFIX_MAX_LENGTH] = - "dns:///"; +class RegistryState { + public: + RegistryState() : default_prefix_(gpr_strdup("dns:///")) {} -void grpc_resolver_registry_init() {} - -void grpc_resolver_registry_shutdown(void) { - for (int i = 0; i < g_number_of_resolvers; i++) { - grpc_resolver_factory_unref(g_all_of_the_resolvers[i]); + void SetDefaultPrefix(const char* default_resolver_prefix) { + GPR_ASSERT(default_resolver_prefix != nullptr); + GPR_ASSERT(*default_resolver_prefix != '\0'); + default_prefix_.reset(gpr_strdup(default_resolver_prefix)); } - // FIXME(ctiller): this should live in grpc_resolver_registry_init, - // however that would have the client_channel plugin call this AFTER we start - // registering resolvers from third party plugins, and so they'd never show - // up. - // We likely need some kind of dependency system for plugins.... what form - // that takes is TBD. - g_number_of_resolvers = 0; -} - -void grpc_resolver_registry_set_default_prefix( - const char* default_resolver_prefix) { - const size_t len = strlen(default_resolver_prefix); - GPR_ASSERT(len < DEFAULT_RESOLVER_PREFIX_MAX_LENGTH && - "default resolver prefix too long"); - GPR_ASSERT(len > 0 && "default resolver prefix can't be empty"); - // By the previous assert, default_resolver_prefix is safe to be copied with a - // plain strcpy. - strcpy(g_default_resolver_prefix, default_resolver_prefix); -} -void grpc_register_resolver_type(grpc_resolver_factory* factory) { - int i; - for (i = 0; i < g_number_of_resolvers; i++) { - GPR_ASSERT(0 != strcmp(factory->vtable->scheme, - g_all_of_the_resolvers[i]->vtable->scheme)); + void RegisterResolverFactory(UniquePtr factory) { + for (size_t i = 0; i < factories_.size(); ++i) { + GPR_ASSERT(strcmp(factories_[i]->scheme(), factory->scheme()) != 0); + } + factories_.push_back(std::move(factory)); } - GPR_ASSERT(g_number_of_resolvers != MAX_RESOLVERS); - grpc_resolver_factory_ref(factory); - g_all_of_the_resolvers[g_number_of_resolvers++] = factory; -} -static grpc_resolver_factory* lookup_factory(const char* name) { - int i; + ResolverFactory* LookupResolverFactory(const char* scheme) const { + for (size_t i = 0; i < factories_.size(); ++i) { + if (strcmp(scheme, factories_[i]->scheme()) == 0) { + return factories_[i].get(); + } + } + return nullptr; + } - for (i = 0; i < g_number_of_resolvers; i++) { - if (0 == strcmp(name, g_all_of_the_resolvers[i]->vtable->scheme)) { - return g_all_of_the_resolvers[i]; + // Returns the factory for the scheme of \a target. If \a target does + // not parse as a URI, prepends \a default_prefix_ and tries again. + // If URI parsing is successful (in either attempt), sets \a uri to + // point to the parsed URI. + // If \a default_prefix_ needs to be prepended, sets \a canonical_target + // to the canonical target string. + ResolverFactory* FindResolverFactory(const char* target, grpc_uri** uri, + char** canonical_target) const { + GPR_ASSERT(uri != nullptr); + *uri = grpc_uri_parse(target, 1); + ResolverFactory* factory = + *uri == nullptr ? nullptr : LookupResolverFactory((*uri)->scheme); + if (factory == nullptr) { + grpc_uri_destroy(*uri); + gpr_asprintf(canonical_target, "%s%s", default_prefix_.get(), target); + *uri = grpc_uri_parse(*canonical_target, 1); + factory = + *uri == nullptr ? nullptr : LookupResolverFactory((*uri)->scheme); + if (factory == nullptr) { + grpc_uri_destroy(grpc_uri_parse(target, 0)); + grpc_uri_destroy(grpc_uri_parse(*canonical_target, 0)); + gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target, + *canonical_target); + } } + return factory; } - return nullptr; + + private: + // We currently support 10 factories without doing additional + // allocation. This number could be raised if there is a case where + // more factories are needed and the additional allocations are + // hurting performance (which is unlikely, since these allocations + // only occur at gRPC initialization time). + InlinedVector, 10> factories_; + UniquePtr default_prefix_; +}; + +static RegistryState* g_state = nullptr; + +} // namespace + +// +// ResolverRegistry::Builder +// + +void ResolverRegistry::Builder::InitRegistry() { + if (g_state == nullptr) g_state = New(); } -grpc_resolver_factory* grpc_resolver_factory_lookup(const char* name) { - grpc_resolver_factory* f = lookup_factory(name); - if (f) grpc_resolver_factory_ref(f); - return f; +void ResolverRegistry::Builder::ShutdownRegistry() { + Delete(g_state); + g_state = nullptr; } -static grpc_resolver_factory* lookup_factory_by_uri(grpc_uri* uri) { - if (!uri) return nullptr; - return lookup_factory(uri->scheme); +void ResolverRegistry::Builder::SetDefaultPrefix( + const char* default_resolver_prefix) { + InitRegistry(); + g_state->SetDefaultPrefix(default_resolver_prefix); } -static grpc_resolver_factory* resolve_factory(const char* target, - grpc_uri** uri, - char** canonical_target) { - grpc_resolver_factory* factory = nullptr; - - GPR_ASSERT(uri != nullptr); - *uri = grpc_uri_parse(target, 1); - factory = lookup_factory_by_uri(*uri); - if (factory == nullptr) { - grpc_uri_destroy(*uri); - gpr_asprintf(canonical_target, "%s%s", g_default_resolver_prefix, target); - *uri = grpc_uri_parse(*canonical_target, 1); - factory = lookup_factory_by_uri(*uri); - if (factory == nullptr) { - grpc_uri_destroy(grpc_uri_parse(target, 0)); - grpc_uri_destroy(grpc_uri_parse(*canonical_target, 0)); - gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target, - *canonical_target); - } - } - return factory; +void ResolverRegistry::Builder::RegisterResolverFactory( + UniquePtr factory) { + InitRegistry(); + g_state->RegisterResolverFactory(std::move(factory)); } -grpc_resolver* grpc_resolver_create(const char* target, - const grpc_channel_args* args, - grpc_pollset_set* pollset_set, - grpc_combiner* combiner) { +// +// ResolverRegistry +// + +ResolverFactory* ResolverRegistry::LookupResolverFactory(const char* scheme) { + GPR_ASSERT(g_state != nullptr); + return g_state->LookupResolverFactory(scheme); +} + +OrphanablePtr ResolverRegistry::CreateResolver( + const char* target, const grpc_channel_args* args, + grpc_pollset_set* pollset_set, grpc_combiner* combiner) { + GPR_ASSERT(g_state != nullptr); grpc_uri* uri = nullptr; char* canonical_target = nullptr; - grpc_resolver_factory* factory = - resolve_factory(target, &uri, &canonical_target); - grpc_resolver* resolver; - grpc_resolver_args resolver_args; - memset(&resolver_args, 0, sizeof(resolver_args)); + ResolverFactory* factory = + g_state->FindResolverFactory(target, &uri, &canonical_target); + ResolverArgs resolver_args; resolver_args.uri = uri; resolver_args.args = args; resolver_args.pollset_set = pollset_set; resolver_args.combiner = combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &resolver_args); + OrphanablePtr resolver = + factory == nullptr ? nullptr : factory->CreateResolver(resolver_args); grpc_uri_destroy(uri); gpr_free(canonical_target); return resolver; } -char* grpc_get_default_authority(const char* target) { +UniquePtr ResolverRegistry::GetDefaultAuthority(const char* target) { + GPR_ASSERT(g_state != nullptr); grpc_uri* uri = nullptr; char* canonical_target = nullptr; - grpc_resolver_factory* factory = - resolve_factory(target, &uri, &canonical_target); - char* authority = grpc_resolver_factory_get_default_authority(factory, uri); + ResolverFactory* factory = + g_state->FindResolverFactory(target, &uri, &canonical_target); + UniquePtr authority = + factory == nullptr ? nullptr : factory->GetDefaultAuthority(uri); grpc_uri_destroy(uri); gpr_free(canonical_target); return authority; } -char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target) { +UniquePtr ResolverRegistry::AddDefaultPrefixIfNeeded(const char* target) { + GPR_ASSERT(g_state != nullptr); grpc_uri* uri = nullptr; char* canonical_target = nullptr; - resolve_factory(target, &uri, &canonical_target); + g_state->FindResolverFactory(target, &uri, &canonical_target); grpc_uri_destroy(uri); - return canonical_target == nullptr ? gpr_strdup(target) : canonical_target; + return UniquePtr(canonical_target == nullptr ? gpr_strdup(target) + : canonical_target); } + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/resolver_registry.h b/src/core/ext/filters/client_channel/resolver_registry.h index bbd30df8da..260336de83 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.h +++ b/src/core/ext/filters/client_channel/resolver_registry.h @@ -20,49 +20,62 @@ #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H #include "src/core/ext/filters/client_channel/resolver_factory.h" +#include "src/core/lib/gprpp/inlined_vector.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/pollset_set.h" -void grpc_resolver_registry_init(); -void grpc_resolver_registry_shutdown(void); +namespace grpc_core { -/** Set the default URI prefix to \a default_prefix. */ -void grpc_resolver_registry_set_default_prefix(const char* default_prefix); +class ResolverRegistry { + public: + /// Methods used to create and populate the ResolverRegistry. + /// NOT THREAD SAFE -- to be used only during global gRPC + /// initialization and shutdown. + class Builder { + public: + /// Global initialization and shutdown hooks. + static void InitRegistry(); + static void ShutdownRegistry(); -/** Register a resolver type. - URI's of \a scheme will be resolved with the given resolver. - If \a priority is greater than zero, then the resolver will be eligible - to resolve names that are passed in with no scheme. Higher priority - resolvers will be tried before lower priority schemes. */ -void grpc_register_resolver_type(grpc_resolver_factory* factory); + /// Sets the default URI prefix to \a default_prefix. + /// Calls InitRegistry() if it has not already been called. + static void SetDefaultPrefix(const char* default_prefix); -/** Create a resolver given \a target. - First tries to parse \a target as a URI. If this succeeds, tries - to locate a registered resolver factory based on the URI scheme. - If parsing or location fails, prefixes default_prefix from - grpc_resolver_registry_init to target, and tries again (if default_prefix - was not NULL). - If a resolver factory was found, use it to instantiate a resolver and - return it. - If a resolver factory was not found, return NULL. - \a args is a set of channel arguments to be included in the result - (typically the set of arguments passed in from the client API). - \a pollset_set is used to drive IO in the name resolution process, it - should not be NULL. */ -grpc_resolver* grpc_resolver_create(const char* target, - const grpc_channel_args* args, - grpc_pollset_set* pollset_set, - grpc_combiner* combiner); + /// Registers a resolver factory. The factory will be used to create a + /// resolver for any URI whose scheme matches that of the factory. + /// Calls InitRegistry() if it has not already been called. + static void RegisterResolverFactory(UniquePtr factory); + }; -/** Find a resolver factory given a name and return an (owned-by-the-caller) - * reference to it */ -grpc_resolver_factory* grpc_resolver_factory_lookup(const char* name); + /// Creates a resolver given \a target. + /// First tries to parse \a target as a URI. If this succeeds, tries + /// to locate a registered resolver factory based on the URI scheme. + /// If parsing fails or there is no factory for the URI's scheme, + /// prepends default_prefix to target and tries again. + /// If a resolver factory is found, uses it to instantiate a resolver and + /// returns it; otherwise, returns nullptr. + /// \a args, \a pollset_set, and \a combiner are passed to the factory's + /// \a CreateResolver() method. + /// \a args are the channel args to be included in resolver results. + /// \a pollset_set is used to drive I/O in the name resolution process. + /// \a combiner is the combiner under which all resolver calls will be run. + static OrphanablePtr CreateResolver(const char* target, + const grpc_channel_args* args, + grpc_pollset_set* pollset_set, + grpc_combiner* combiner); -/** Given a target, return a (freshly allocated with gpr_malloc) string - representing the default authority to pass from a client. */ -char* grpc_get_default_authority(const char* target); + /// Returns the default authority to pass from a client for \a target. + static UniquePtr GetDefaultAuthority(const char* target); -/** Returns a newly allocated string containing \a target, adding the - default prefix if needed. */ -char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target); + /// Returns \a target with the default prefix prepended, if needed. + static UniquePtr AddDefaultPrefixIfNeeded(const char* target); + + /// Returns the resolver factory for \a scheme. + /// Caller does NOT own the return value. + static ResolverFactory* LookupResolverFactory(const char* scheme); +}; + +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index 6a1b70964d..ef1d3fb53b 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -52,13 +52,13 @@ static grpc_channel* client_channel_factory_create_channel( return nullptr; } // Add channel arg containing the server URI. - grpc_arg arg = grpc_channel_arg_string_create( - (char*)GRPC_ARG_SERVER_URI, - grpc_resolver_factory_add_default_prefix_if_needed(target)); + grpc_core::UniquePtr canonical_target = + grpc_core::ResolverRegistry::AddDefaultPrefixIfNeeded(target); + grpc_arg arg = grpc_channel_arg_string_create((char*)GRPC_ARG_SERVER_URI, + canonical_target.get()); const char* to_remove[] = {GRPC_ARG_SERVER_URI}; grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); - gpr_free(arg.value.string); grpc_channel* channel = grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); grpc_channel_args_destroy(new_args); 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 27c5b96a4c..d39c362cd3 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 @@ -161,13 +161,13 @@ static grpc_channel* client_channel_factory_create_channel( return nullptr; } // Add channel arg containing the server URI. - grpc_arg arg = grpc_channel_arg_string_create( - (char*)GRPC_ARG_SERVER_URI, - grpc_resolver_factory_add_default_prefix_if_needed(target)); + grpc_core::UniquePtr canonical_target = + grpc_core::ResolverRegistry::AddDefaultPrefixIfNeeded(target); + grpc_arg arg = grpc_channel_arg_string_create((char*)GRPC_ARG_SERVER_URI, + canonical_target.get()); const char* to_remove[] = {GRPC_ARG_SERVER_URI}; grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); - gpr_free(arg.value.string); grpc_channel* channel = grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); grpc_channel_args_destroy(new_args); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 3d8ee10443..5b8edfe9bf 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -269,7 +269,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/proxy_mapper.cc', 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver_factory.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 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 18a795fbcb..8cafadf05a 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -79,17 +79,17 @@ static grpc_ares_request* my_dns_lookup_ares( return nullptr; } -static grpc_resolver* create_resolver(const char* name) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); +static grpc_core::OrphanablePtr create_resolver( + const char* name) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(name, 0); GPR_ASSERT(uri); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); grpc_uri_destroy(uri); return resolver; } @@ -112,7 +112,7 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) { } typedef struct next_args { - grpc_resolver* resolver; + grpc_core::Resolver* resolver; grpc_channel_args** result; grpc_closure* on_complete; } next_args; @@ -120,21 +120,21 @@ typedef struct next_args { static void call_resolver_next_now_lock_taken(void* arg, grpc_error* error_unused) { next_args* a = static_cast(arg); - grpc_resolver_next_locked(a->resolver, a->result, a->on_complete); + a->resolver->NextLocked(a->result, a->on_complete); gpr_free(a); } -static void call_resolver_next_after_locking(grpc_resolver* resolver, +static void call_resolver_next_after_locking(grpc_core::Resolver* resolver, grpc_channel_args** result, - grpc_closure* on_complete) { + grpc_closure* on_complete, + grpc_combiner* combiner) { next_args* a = static_cast(gpr_malloc(sizeof(*a))); a->resolver = resolver; a->result = result; a->on_complete = on_complete; - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, - grpc_combiner_scheduler(resolver->combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, + grpc_combiner_scheduler(combiner)), + GRPC_ERROR_NONE); } int main(int argc, char** argv) { @@ -149,12 +149,14 @@ int main(int argc, char** argv) { { grpc_core::ExecCtx exec_ctx; - grpc_resolver* resolver = create_resolver("dns:test"); + grpc_core::OrphanablePtr resolver = + create_resolver("dns:test"); gpr_event ev1; gpr_event_init(&ev1); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(5, &ev1)); GPR_ASSERT(result == nullptr); @@ -162,14 +164,14 @@ int main(int argc, char** argv) { gpr_event ev2; gpr_event_init(&ev2); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(30, &ev2)); GPR_ASSERT(result != nullptr); grpc_channel_args_destroy(result); - GRPC_RESOLVER_UNREF(resolver, "test"); GRPC_COMBINER_UNREF(g_combiner, "test"); } 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 64342b48c8..9402a605b3 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -23,6 +23,7 @@ #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "test/core/util/test_config.h" @@ -131,13 +132,13 @@ static void poll_pollset_until_request_done(iomgr_args* args) { gpr_event_set(&args->ev, (void*)1); } -typedef struct on_resolution_cb_arg { - const char* uri_str; - grpc_resolver* resolver; - grpc_channel_args* result; - grpc_millis delay_before_second_resolution; - bool using_cares; -} on_resolution_cb_arg; +struct OnResolutionCallbackArg { + const char* uri_str = nullptr; + grpc_core::OrphanablePtr resolver; + grpc_channel_args* result = nullptr; + grpc_millis delay_before_second_resolution = 0; + bool using_cares = false; +}; // Counter for the number of times a resolution notification callback has been // invoked. @@ -147,7 +148,7 @@ static int g_on_resolution_invocations_count; bool g_all_callbacks_invoked; void on_third_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast(arg); + OnResolutionCallbackArg* cb_arg = static_cast(arg); GPR_ASSERT(error == GRPC_ERROR_NONE); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); @@ -159,8 +160,7 @@ void on_third_resolution(void* arg, grpc_error* error) { // period. GPR_ASSERT(g_on_resolution_invocations_count == 3); GPR_ASSERT(g_resolution_count == 2); - grpc_resolver_shutdown_locked(cb_arg->resolver); - GRPC_RESOLVER_UNREF(cb_arg->resolver, "on_third_resolution"); + cb_arg->resolver.reset(); if (cb_arg->using_cares) { gpr_atm_rel_store(&g_iomgr_args.done_atm, 1); gpr_mu_lock(g_iomgr_args.mu); @@ -168,12 +168,12 @@ void on_third_resolution(void* arg, grpc_error* error) { grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); gpr_mu_unlock(g_iomgr_args.mu); } - gpr_free(cb_arg); + grpc_core::Delete(cb_arg); g_all_callbacks_invoked = true; } void on_second_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast(arg); + OnResolutionCallbackArg* cb_arg = static_cast(arg); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); @@ -187,11 +187,11 @@ void on_second_resolution(void* arg, grpc_error* error) { GPR_ASSERT(g_resolution_count == 1); grpc_core::ExecCtx::Get()->TestOnlySetNow( cb_arg->delay_before_second_resolution * 2); - grpc_resolver_next_locked( - cb_arg->resolver, &cb_arg->result, + cb_arg->resolver->NextLocked( + &cb_arg->result, GRPC_CLOSURE_CREATE(on_third_resolution, arg, grpc_combiner_scheduler(g_combiner))); - grpc_resolver_channel_saw_error_locked(cb_arg->resolver); + cb_arg->resolver->RequestReresolutionLocked(); if (cb_arg->using_cares) { gpr_mu_lock(g_iomgr_args.mu); GRPC_LOG_IF_ERROR("pollset_kick", @@ -201,14 +201,14 @@ void on_second_resolution(void* arg, grpc_error* error) { } void on_first_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast(arg); + OnResolutionCallbackArg* cb_arg = static_cast(arg); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); - grpc_resolver_next_locked( - cb_arg->resolver, &cb_arg->result, + cb_arg->resolver->NextLocked( + &cb_arg->result, GRPC_CLOSURE_CREATE(on_second_resolution, arg, grpc_combiner_scheduler(g_combiner))); - grpc_resolver_channel_saw_error_locked(cb_arg->resolver); + cb_arg->resolver->RequestReresolutionLocked(); gpr_log(GPR_INFO, "1st: g_on_resolution_invocations_count: %d, g_resolution_count: %d", g_on_resolution_invocations_count, g_resolution_count); @@ -225,15 +225,16 @@ void on_first_resolution(void* arg, grpc_error* error) { } static void start_test_under_combiner(void* arg, grpc_error* error) { - on_resolution_cb_arg* res_cb_arg = static_cast(arg); - grpc_resolver* resolver; - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); + OnResolutionCallbackArg* res_cb_arg = + static_cast(arg); + + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0); - grpc_resolver_args args; gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", res_cb_arg->uri_str, - factory->vtable->scheme); - GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + factory->scheme()); + GPR_ASSERT(uri != nullptr); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; g_on_resolution_invocations_count = 0; @@ -248,25 +249,23 @@ static void start_test_under_combiner(void* arg, grpc_error* error) { auto* cooldown_channel_args = grpc_channel_args_copy_and_add(nullptr, &cooldown_arg, 1); args.args = cooldown_channel_args; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + res_cb_arg->resolver = factory->CreateResolver(args); grpc_channel_args_destroy(cooldown_channel_args); - GPR_ASSERT(resolver != nullptr); - res_cb_arg->resolver = resolver; + GPR_ASSERT(res_cb_arg->resolver != nullptr); res_cb_arg->delay_before_second_resolution = kMinResolutionPeriodMs; // First resolution, would incur in system-level resolution. - grpc_resolver_next_locked( - resolver, &res_cb_arg->result, + res_cb_arg->resolver->NextLocked( + &res_cb_arg->result, GRPC_CLOSURE_CREATE(on_first_resolution, res_cb_arg, grpc_combiner_scheduler(g_combiner))); grpc_uri_destroy(uri); - grpc_resolver_factory_unref(factory); } static void test_cooldown(bool using_cares) { grpc_core::ExecCtx exec_ctx; if (using_cares) iomgr_args_init(&g_iomgr_args); - on_resolution_cb_arg* res_cb_arg = - static_cast(gpr_zalloc(sizeof(*res_cb_arg))); + OnResolutionCallbackArg* res_cb_arg = + grpc_core::New(); res_cb_arg->uri_str = "dns:127.0.0.1"; res_cb_arg->using_cares = using_cares; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 80667908ef..e3fba2838c 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -27,47 +27,46 @@ static grpc_combiner* g_combiner; -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); grpc_uri_destroy(uri); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory* dns; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - dns = grpc_resolver_factory_lookup("dns"); + grpc_core::ResolverFactory* dns = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); test_succeeds(dns, "dns:10.2.1.1"); test_succeeds(dns, "dns:10.2.1.1:1234"); @@ -78,7 +77,6 @@ int main(int argc, char** argv) { test_fails(dns, "ipv4://8.8.8.8/8.8.8.8:8888"); } - grpc_resolver_factory_unref(dns); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index 9c11c01021..03af8954e1 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -27,25 +27,26 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/test_config.h" -static grpc_resolver* build_fake_resolver( +static grpc_core::OrphanablePtr build_fake_resolver( grpc_combiner* combiner, - grpc_fake_resolver_response_generator* response_generator) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake"); + grpc_core::FakeResolverResponseGenerator* response_generator) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("fake"); grpc_arg generator_arg = - grpc_fake_resolver_response_generator_arg(response_generator); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator); grpc_channel_args channel_args = {1, &generator_arg}; + grpc_core::ResolverArgs args; args.args = &channel_args; args.combiner = combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); return resolver; } @@ -57,10 +58,11 @@ typedef struct on_resolution_arg { // Callback to check the resolution result is as expected. void on_resolution_cb(void* arg, grpc_error* error) { + if (error != GRPC_ERROR_NONE) return; on_resolution_arg* res = static_cast(arg); // We only check the addresses channel arg because that's the only one // explicitly set by the test via - // grpc_fake_resolver_response_generator_set_response. + // FakeResolverResponseGenerator::SetResponse(). const grpc_lb_addresses* actual_lb_addresses = grpc_lb_addresses_find_channel_arg(res->resolver_result); const grpc_lb_addresses* expected_lb_addresses = @@ -115,27 +117,27 @@ static void test_fake_resolver() { grpc_core::ExecCtx exec_ctx; grpc_combiner* combiner = grpc_combiner_create(); // Create resolver. - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); - grpc_resolver* resolver = build_fake_resolver(combiner, response_generator); - GPR_ASSERT(resolver != nullptr); + grpc_core::RefCountedPtr + response_generator = + grpc_core::MakeRefCounted(); + grpc_core::OrphanablePtr resolver = + build_fake_resolver(combiner, response_generator.get()); + GPR_ASSERT(resolver.get() != nullptr); // Test 1: normal resolution. - // next_results != NULL, results_upon_error == NULL, last_used_results == + // next_results != NULL, reresolution_results == NULL, last_used_results == // NULL. Expected response is next_results. grpc_channel_args* results = create_new_resolver_result(); on_resolution_arg on_res_arg = create_on_resolution_arg(results); grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 2: update resolution. - // next_results != NULL, results_upon_error == NULL, last_used_results != + // next_results != NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is next_results. results = create_new_resolver_result(); grpc_channel_args* last_used_results = grpc_channel_args_copy(results); @@ -143,61 +145,55 @@ static void test_fake_resolver() { on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 3: fallback re-resolution. - // next_results == NULL, results_upon_error == NULL, last_used_results != + // next_results == NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is last_used_results. on_res_arg = create_on_resolution_arg(last_used_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 4: normal re-resolution. - // next_results == NULL, results_upon_error != NULL, last_used_results != - // NULL. Expected response is results_upon_error. - grpc_channel_args* results_upon_error = create_new_resolver_result(); + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + grpc_channel_args* reresolution_results = create_new_resolver_result(); on_res_arg = - create_on_resolution_arg(grpc_channel_args_copy(results_upon_error)); + create_on_resolution_arg(grpc_channel_args_copy(reresolution_results)); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - // Set results_upon_error. - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator, results_upon_error); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Set reresolution_results. + response_generator->SetReresolutionResponse(reresolution_results); // Flush here to guarantee that the response has been set. grpc_core::ExecCtx::Get()->Flush(); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 5: repeat re-resolution. - // next_results == NULL, results_upon_error != NULL, last_used_results != - // NULL. Expected response is results_upon_error. - on_res_arg = create_on_resolution_arg(results_upon_error); + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + on_res_arg = create_on_resolution_arg(reresolution_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 6: normal resolution. - // next_results != NULL, results_upon_error != NULL, last_used_results != + // next_results != NULL, reresolution_results != NULL, last_used_results != // NULL. Expected response is next_results. results = create_new_resolver_result(); last_used_results = grpc_channel_args_copy(results); @@ -205,28 +201,24 @@ static void test_fake_resolver() { on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 7: fallback re-resolution. - // next_results == NULL, results_upon_error == NULL, last_used_results != + // next_results == NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is last_used_results. on_res_arg = create_on_resolution_arg(last_used_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - // Reset results_upon_error. - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator, nullptr); - // Flush here to guarantee that results_upon_error has been reset. + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Reset reresolution_results. + response_generator->SetReresolutionResponse(nullptr); + // Flush here to guarantee that reresolution_results has been reset. grpc_core::ExecCtx::Get()->Flush(); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); @@ -234,16 +226,15 @@ static void test_fake_resolver() { // Requesting a new resolution without setting the response shouldn't trigger // the resolution callback. memset(&on_res_arg, 0, sizeof(on_res_arg)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr); // Clean up. GRPC_COMBINER_UNREF(combiner, "test_fake_resolver"); - GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver"); - grpc_fake_resolver_response_generator_unref(response_generator); } int main(int argc, char** argv) { diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc index 07ee133ee3..b9287c2468 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc @@ -40,18 +40,18 @@ void on_resolution_cb(void* arg, grpc_error* error) { grpc_channel_args_destroy(res->resolver_result); } -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); on_resolution_arg on_res_arg; @@ -60,40 +60,39 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) { grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_uri_destroy(uri); /* Flush ExecCtx to avoid stack-use-after-scope on on_res_arg which is * accessed in the closure on_resolution_cb */ grpc_core::ExecCtx::Get()->Flush(); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory *ipv4, *ipv6; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - ipv4 = grpc_resolver_factory_lookup("ipv4"); - ipv6 = grpc_resolver_factory_lookup("ipv6"); + grpc_core::ResolverFactory* ipv4 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv4"); + grpc_core::ResolverFactory* ipv6 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv6"); test_fails(ipv4, "ipv4:10.2.1.1"); test_succeeds(ipv4, "ipv4:10.2.1.1:1234"); @@ -109,9 +108,6 @@ int main(int argc, char** argv) { test_fails(ipv6, "ipv6:[::]:123456"); test_fails(ipv6, "ipv6:www.google.com"); - grpc_resolver_factory_unref(ipv4); - grpc_resolver_factory_unref(ipv6); - { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc index 37247f89d0..56f4f602e8 100644 --- a/test/core/surface/channel_create_test.cc +++ b/test/core/surface/channel_create_test.cc @@ -29,8 +29,8 @@ void test_unknown_scheme_target(void) { grpc_channel* chan; /* avoid default prefix */ - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr); GPR_ASSERT(chan != nullptr); diff --git a/test/core/surface/secure_channel_create_test.cc b/test/core/surface/secure_channel_create_test.cc index fa22cd6873..c10d6796a7 100644 --- a/test/core/surface/secure_channel_create_test.cc +++ b/test/core/surface/secure_channel_create_test.cc @@ -28,8 +28,8 @@ #include "test/core/util/test_config.h" void test_unknown_scheme_target(void) { - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); grpc_channel_credentials* creds = grpc_fake_transport_security_credentials_create(); grpc_channel* chan = diff --git a/test/cpp/client/client_channel_stress_test.cc b/test/cpp/client/client_channel_stress_test.cc index 80d1583333..bb8553f56a 100644 --- a/test/cpp/client/client_channel_stress_test.cc +++ b/test/cpp/client/client_channel_stress_test.cc @@ -36,6 +36,7 @@ #include #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -230,8 +231,7 @@ class ClientChannelStressTest { } grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -253,9 +253,10 @@ class ClientChannelStressTest { void CreateStub() { ChannelArguments args; - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted(); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -298,7 +299,6 @@ class ClientChannelStressTest { for (size_t i = 0; i < backends_.size(); ++i) { backend_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } std::atomic_bool shutdown_{false}; @@ -310,7 +310,8 @@ class ClientChannelStressTest { std::vector> balancers_; std::vector> backend_servers_; std::vector> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr + response_generator_; std::vector client_threads_; }; diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index ee5adbc6fa..386d18e95d 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -40,6 +40,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -119,11 +120,11 @@ class ClientLbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted(); } void TearDown() override { - grpc_fake_resolver_response_generator_unref(response_generator_); for (size_t i = 0; i < servers_.size(); ++i) { servers_[i]->Shutdown(); } @@ -153,13 +154,9 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } - const grpc_arg fake_addresses = - grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); - grpc_fake_resolver_response_generator_set_response(response_generator_, - fake_result); - grpc_channel_args_destroy(fake_result); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -178,13 +175,9 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } - const grpc_arg fake_addresses = - grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator_, fake_result); - grpc_channel_args_destroy(fake_result); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -206,7 +199,7 @@ class ClientLbEnd2endTest : public ::testing::Test { args.SetLoadBalancingPolicyName(lb_policy_name); } // else, default to pick first args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); return CreateCustomChannel("fake:///", InsecureChannelCredentials(), args); } @@ -323,7 +316,8 @@ class ClientLbEnd2endTest : public ::testing::Test { const grpc::string server_host_; std::unique_ptr stub_; std::vector> servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr + response_generator_; const grpc::string kRequestMessage_; }; diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 5591acf880..89c9c2bf76 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -35,6 +35,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -339,7 +340,8 @@ class GrpclbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted(); // Start the backends. for (size_t i = 0; i < num_backends_; ++i) { backends_.emplace_back(new BackendServiceImpl()); @@ -363,7 +365,6 @@ class GrpclbEnd2endTest : public ::testing::Test { for (size_t i = 0; i < balancers_.size(); ++i) { if (balancers_[i]->Shutdown()) balancer_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } void SetNextResolutionAllBalancers() { @@ -378,7 +379,7 @@ class GrpclbEnd2endTest : public ::testing::Test { ChannelArguments args; args.SetGrpclbFallbackTimeout(fallback_timeout); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -478,20 +479,18 @@ class GrpclbEnd2endTest : public ::testing::Test { CreateLbAddressesFromAddressDataList(address_data); grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } - void SetNextResolutionUponError( + void SetNextReresolutionResponse( const std::vector& address_data) { grpc_core::ExecCtx exec_ctx; grpc_lb_addresses* addresses = CreateLbAddressesFromAddressDataList(address_data); grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator_, &fake_result); + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -593,7 +592,8 @@ class GrpclbEnd2endTest : public ::testing::Test { std::vector> balancers_; std::vector> backend_servers_; std::vector> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr + response_generator_; const grpc::string kRequestMessage_ = "Live long and prosper."; }; diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 4a9fd7ce76..06ab8c3ff8 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -43,6 +43,7 @@ #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/lib/surface/channel.h" @@ -558,8 +559,8 @@ static void setup_client(const server_fixture* lb_server, const char* backends_name = lb_server->servers_hostport; gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); + auto response_generator = + grpc_core::MakeRefCounted(); grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr); char* lb_uri_str; @@ -578,25 +579,22 @@ static void setup_client(const server_fixture* lb_server, grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); grpc_lb_addresses_destroy(addresses); - const grpc_arg new_args[] = { + grpc_arg new_args[] = { grpc_fake_transport_expected_targets_arg(expected_target_names), - grpc_fake_resolver_response_generator_arg(response_generator)}; + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator.get())}; - grpc_channel_args* args = grpc_channel_args_copy_and_add( - nullptr, new_args, GPR_ARRAY_SIZE(new_args)); - gpr_free(expected_target_names); + grpc_channel_args args = {GPR_ARRAY_SIZE(new_args), new_args}; cf->cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel_credentials* fake_creds = grpc_fake_transport_security_credentials_create(); cf->client = - grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr); - grpc_fake_resolver_response_generator_set_response(response_generator, - fake_result); + grpc_secure_channel_create(fake_creds, cf->server_uri, &args, nullptr); + response_generator->SetResponse(fake_result); grpc_channel_args_destroy(fake_result); grpc_channel_credentials_unref(fake_creds); - grpc_channel_args_destroy(args); - grpc_fake_resolver_response_generator_unref(response_generator); + gpr_free(expected_target_names); } static void teardown_client(client_fixture* cf) { diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index aad2fa5f75..f4be064305 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -39,6 +39,7 @@ #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/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -61,11 +62,9 @@ using namespace gflags; DEFINE_string(target_name, "", "Target name to resolve."); DEFINE_string(expected_addrs, "", - "Comma-separated list of expected " - "',;,;...' " - "addresses of " - "backend and/or balancers. 'is_balancer' should be bool, i.e. " - "true or false."); + "List of expected backend or balancer addresses in the form " + "',;,;...'. " + "'is_balancer' should be bool, i.e. true or false."); DEFINE_string(expected_chosen_service_config, "", "Expected service config json string that gets chosen (no " "whitespace). Empty for none."); @@ -102,12 +101,10 @@ vector ParseExpectedAddrs(std::string expected_addrs) { // get the next , (v4 or v6) size_t next_comma = expected_addrs.find(","); if (next_comma == std::string::npos) { - gpr_log( - GPR_ERROR, - "Missing ','. Expected_addrs arg should be a semi-colon-separated " - "list of " - ", pairs. Left-to-be-parsed arg is |%s|", - expected_addrs.c_str()); + gpr_log(GPR_ERROR, + "Missing ','. Expected_addrs arg should be a semicolon-separated " + "list of , pairs. Left-to-be-parsed arg is |%s|", + expected_addrs.c_str()); abort(); } std::string next_addr = expected_addrs.substr(0, next_comma); @@ -125,7 +122,7 @@ vector ParseExpectedAddrs(std::string expected_addrs) { } if (out.size() == 0) { gpr_log(GPR_ERROR, - "expected_addrs arg should be a comma-separated list of " + "expected_addrs arg should be a semicolon-separated list of " ", pairs"); abort(); } @@ -287,17 +284,16 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { FLAGS_local_dns_server_address.c_str(), FLAGS_target_name.c_str())); // create resolver and resolve - grpc_resolver* resolver = - grpc_resolver_create(whole_uri, nullptr, args.pollset_set, args.lock); + grpc_core::OrphanablePtr resolver = + grpc_core::ResolverRegistry::CreateResolver(whole_uri, nullptr, + 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_resolver_next_locked(resolver, &args.channel_args, - &on_resolver_result_changed); + resolver->NextLocked(&args.channel_args, &on_resolver_result_changed); grpc_core::ExecCtx::Get()->Flush(); PollPollsetUntilRequestDone(&args); - GRPC_RESOLVER_UNREF(resolver, nullptr); ArgsFinish(&args); } diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 1f9c1b953b..f94ef8bd25 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -931,7 +931,6 @@ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h \ src/core/ext/filters/client_channel/resolver/sockaddr/README.md \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ -src/core/ext/filters/client_channel/resolver_factory.cc \ src/core/ext/filters/client_channel/resolver_factory.h \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 17e75cc2e9..8e6ac0ddd0 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8883,7 +8883,6 @@ "src/core/ext/filters/client_channel/proxy_mapper_registry.h", "src/core/ext/filters/client_channel/resolver.cc", "src/core/ext/filters/client_channel/resolver.h", - "src/core/ext/filters/client_channel/resolver_factory.cc", "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/resolver_registry.h", -- cgit v1.2.3